Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [WIP] New package: openjdk17-17.0.1+12
@ 2022-01-11  8:29 classabbyamp
  2022-01-12 21:56 ` [PR PATCH] [Updated] " classabbyamp
                   ` (48 more replies)
  0 siblings, 49 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-11  8:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

There is a new pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!-- 
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 170804 bytes --]

From d6416ff36aca1f2342a3f7f915a3e8b78cc5383a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/7] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 90a124d936a2eae2e61c77c9c8135bfcc8ba7286 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 2/7] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 0b400a01544958427c3261422ecca20a7dd065c9 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 3/7] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a24b217dd792124f265bc7c6dc315e4976a0eec3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 4/7] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 215e9976732601f90e0322c43453367f525cd586 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 5/7] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From bfba50fba94312606ce822e9a863850792390ad1 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 6/7] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f89874d0ee0b5da50f13446ccb597d0cd5eff9a2 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 7/7] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index 999d3ad714b8..1b8c55aefebd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
@ 2022-01-12 21:56 ` classabbyamp
  2022-01-12 21:58 ` classabbyamp
                   ` (47 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-12 21:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

xlint currently fails because support for the SPDX `WITH` operator is not available in a tagged version yet, but [does exist](https://github.com/leahneukirchen/xtools/blob/master/xlint#L380)

#### Testing the changes
- I tested the changes in this PR: **briefly**
- have tested very briefly on x86_64-glibc, will need help testing on musl

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!-- 
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 173982 bytes --]

From d6416ff36aca1f2342a3f7f915a3e8b78cc5383a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 90a124d936a2eae2e61c77c9c8135bfcc8ba7286 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 0b400a01544958427c3261422ecca20a7dd065c9 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a24b217dd792124f265bc7c6dc315e4976a0eec3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 215e9976732601f90e0322c43453367f525cd586 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From bfba50fba94312606ce822e9a863850792390ad1 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f89874d0ee0b5da50f13446ccb597d0cd5eff9a2 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index 999d3ad714b8..1b8c55aefebd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 250d46924bfe1f60edba6a25566a1158c21f786b Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 8/8] fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template | 2 +-
 srcpkgs/openjdk13-bootstrap/template | 2 +-
 srcpkgs/openjdk14-bootstrap/template | 2 +-
 srcpkgs/openjdk15-bootstrap/template | 2 +-
 srcpkgs/openjdk16-bootstrap/template | 2 +-
 srcpkgs/openjdk17/template           | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..33ca1dfde7b0 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..947be7aa9994 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..16ed20005bba 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..18f75091993a 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..06b6e70fb0e2 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..16bc90b2b312 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
  2022-01-12 21:56 ` [PR PATCH] [Updated] " classabbyamp
@ 2022-01-12 21:58 ` classabbyamp
  2022-01-13  4:23 ` classabbyamp
                   ` (46 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-12 21:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

xlint currently fails because support for the SPDX `WITH` operator is not available in a tagged version yet, but [does exist](https://github.com/leahneukirchen/xtools/blob/master/xlint#L380)

#### Testing the changes
- I tested the changes in this PR: **briefly**
- have tested very briefly on x86_64-glibc, will need help testing on musl

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!-- 
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 173982 bytes --]

From e03dce465c48e67ce11ad9c8f00bd73a64223231 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From a22798fde0e1050535e026922daee5f3c91e315f Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 65daec5022acb77d2268c4467eb22590c8b469d7 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 643bd30ea2ddd08597b5b0deb0cf78ce69ef5688 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6909c1668ec668d14fc64c0f03e75358777c4b73 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6cd82fd0c3d7f508850054f1939445a7281c01db Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 17ce84ef5471a33b4627337efd77c1274a86c13b Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 5e0ba63e6758890bb3f3c79e5a93de0f305775a6 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 8/8] fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template | 2 +-
 srcpkgs/openjdk13-bootstrap/template | 2 +-
 srcpkgs/openjdk14-bootstrap/template | 2 +-
 srcpkgs/openjdk15-bootstrap/template | 2 +-
 srcpkgs/openjdk16-bootstrap/template | 2 +-
 srcpkgs/openjdk17/template           | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..33ca1dfde7b0 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..947be7aa9994 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..16ed20005bba 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..18f75091993a 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..06b6e70fb0e2 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..16bc90b2b312 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -slNp1 -i "$f"
 		done
 	fi
 }

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
  2022-01-12 21:56 ` [PR PATCH] [Updated] " classabbyamp
  2022-01-12 21:58 ` classabbyamp
@ 2022-01-13  4:23 ` classabbyamp
  2022-01-14 21:59 ` classabbyamp
                   ` (45 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-13  4:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

xlint currently fails because support for the SPDX `WITH` operator is not available in a tagged version yet, but [does exist](https://github.com/leahneukirchen/xtools/blob/master/xlint#L380)

#### Testing the changes
- I tested the changes in this PR: **briefly**
- have tested very briefly on x86_64-glibc, will need help testing on musl

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!-- 
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 174882 bytes --]

From e03dce465c48e67ce11ad9c8f00bd73a64223231 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From a22798fde0e1050535e026922daee5f3c91e315f Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 65daec5022acb77d2268c4467eb22590c8b469d7 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 643bd30ea2ddd08597b5b0deb0cf78ce69ef5688 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6909c1668ec668d14fc64c0f03e75358777c4b73 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6cd82fd0c3d7f508850054f1939445a7281c01db Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 17ce84ef5471a33b4627337efd77c1274a86c13b Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 32053ade7517b03bcb9f40cabc330a9a68fa30d7 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 8/8] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (2 preceding siblings ...)
  2022-01-13  4:23 ` classabbyamp
@ 2022-01-14 21:59 ` classabbyamp
  2022-01-15 17:09 ` classabbyamp
                   ` (44 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-14 21:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for my native architecture, (x86_64, x86_64-musl)
- I built this PR locally for these architectures (if supported. mark crossbuilds):

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || ✔ | ✔ |
| x86_64-musl || ✔ | ✔ |
| i686 | ✔ | | |
| i686-musl | ✔ | | |
| aarch64 | ✔ | | |
| aarch64-musl | ✔ | | |
| armv7l | ✔ | | |
| armv6l-musl | ✔ | | |

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 203222 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/10] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/10] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/10] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/10] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/10] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/10] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/10] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/10] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/10] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/10] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (3 preceding siblings ...)
  2022-01-14 21:59 ` classabbyamp
@ 2022-01-15 17:09 ` classabbyamp
  2022-01-15 17:10 ` classabbyamp
                   ` (43 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-15 17:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for my native architecture, (x86_64, x86_64-musl)
- I built this PR locally for these architectures (if supported. mark crossbuilds):

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || ✔ | ✔ |
| x86_64-musl || ✔ | ✔ |
| i686 | ✔ | | |
| i686-musl | ✔ | | |
| aarch64 | ✔ | | |
| aarch64-musl | ✔ | | |
| armv7l | ✔ | | |
| armv6l-musl | ✔ | | |

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 210613 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/11] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/11] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/11] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/11] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/11] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/11] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/11] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/11] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/11] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/11] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From b890b3cc9d68197fe99738318b1804e98b61c4b0 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/11] openjdk17: TEMP

---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (4 preceding siblings ...)
  2022-01-15 17:09 ` classabbyamp
@ 2022-01-15 17:10 ` classabbyamp
  2022-01-15 17:11 ` classabbyamp
                   ` (42 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-15 17:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for my native architecture, (x86_64, x86_64-musl)
- I built this PR locally for these architectures (if supported. mark crossbuilds):

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || ✔ | ✔ |
| x86_64-musl || ✔ | ✔ |
| i686 | ✔ | | |
| i686-musl | ✔ | | |
| aarch64 | ✔ | | |
| aarch64-musl | ✔ | | |
| armv7l | ✔ | | |
| armv6l-musl | ✔ | | |

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 210621 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/11] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/11] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/11] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/11] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/11] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/11] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/11] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/11] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/11] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/11] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From 9f8949c0e109db2d52b7f1da73c05a7de55fcace Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/11] openjdk17: TEMP

ci-skip
---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (5 preceding siblings ...)
  2022-01-15 17:10 ` classabbyamp
@ 2022-01-15 17:11 ` classabbyamp
  2022-01-15 17:58 ` Duncaen
                   ` (41 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-15 17:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
[ci-skip]

#### Local build testing
- I built this PR locally for my native architecture, (x86_64, x86_64-musl)
- I built this PR locally for these architectures (if supported. mark crossbuilds):

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || ✔ | ✔ |
| x86_64-musl || ✔ | ✔ |
| i686 | ✔ | | |
| i686-musl | ✔ | | |
| aarch64 | ✔ | | |
| aarch64-musl | ✔ | | |
| armv7l | ✔ | | |
| armv6l-musl | ✔ | | |

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 210621 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/11] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/11] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/11] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/11] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/11] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/11] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/11] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/11] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/11] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/11] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From 81652712bd44e6ad579c4af312721a7dda5e9e14 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/11] openjdk17: TEMP

ci-skip
---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (6 preceding siblings ...)
  2022-01-15 17:11 ` classabbyamp
@ 2022-01-15 17:58 ` Duncaen
  2022-01-15 17:59 ` Duncaen
                   ` (40 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Duncaen @ 2022-01-15 17:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1013725885

Comment:
You don't have to cross build i686, you can use a i686 masterdir on x86_64* systems like you do with a different libc masterdir.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (7 preceding siblings ...)
  2022-01-15 17:58 ` Duncaen
@ 2022-01-15 17:59 ` Duncaen
  2022-01-15 18:46 ` classabbyamp
                   ` (39 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Duncaen @ 2022-01-15 17:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1013725885

Comment:
You don't have to cross build i686, you can use a i686 masterdir on x86_64* systems like you do with a different libc masterdir. (this is how its done on the build server too)

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (8 preceding siblings ...)
  2022-01-15 17:59 ` Duncaen
@ 2022-01-15 18:46 ` classabbyamp
  2022-01-16  2:53 ` [PR PATCH] [Updated] " classabbyamp
                   ` (38 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-15 18:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1013734108

Comment:
ok thanks, i was about to ask that on irc

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (9 preceding siblings ...)
  2022-01-15 18:46 ` classabbyamp
@ 2022-01-16  2:53 ` classabbyamp
  2022-01-16  2:57 ` classabbyamp
                   ` (37 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-16  2:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2145 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✘ (`Unknown test selection: 'gtest'`) <br> 16 ✘ (`Unknown test selection: 'gtest'`) <br> 17 ✘ (`Unknown test selection: 'gtest'`) |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✘ (`Unknown test selection: 'gtest'`) <br> 16 ✘ (`Unknown test selection: 'gtest'`) <br> 17 ✘ (`Unknown test selection: 'gtest'`) |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 | 12 ✔ <br> 13 ✔ <br> 14 ✘ (2 tests fail) <br> 15 ✘ (`Unknown test selection: 'gtest'`) <br> 16 ✘ (`Unknown test selection: 'gtest'`) <br> 17 ✘ (`Unknown test selection: 'gtest'`) |
| aarch64 | ✔ | 17 | 17 |
| aarch64-musl | ✔ | 17 | 17 |
| armv7l | ✔ | 17 | 17 |
| armv6l-musl | ✔ | 17 | 17 |

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 213371 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/12] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/12] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/12] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/12] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/12] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/12] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/12] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/12] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/12] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/12] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From 81652712bd44e6ad579c4af312721a7dda5e9e14 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/12] openjdk17: TEMP

ci-skip
---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

From 9e7544ef0bb5273368dd4a1b5c5295c8586ba62c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 21:53:23 -0500
Subject: [PATCH 12/12] openjdk17: TEMP

---
 srcpkgs/openjdk17/template | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 602730ee0519..ae04218d9685 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,4 +1,5 @@
 # Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -34,13 +35,14 @@ makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
 depends="openjdk17-jre-${version}_${revision}"
-provides="java-environment-${version}_1"
-short_desc="OpenJDK Java Development Kit"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -166,6 +168,10 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -195,25 +201,3 @@ openjdk17-src_package() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
-
-openjdk17-jre_package() {
-	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
-	provides="java-runtime-${version}_1"
-	short_desc+=" - runtime components"
-	alternatives="
-	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
-	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
-	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
-	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
-	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
-	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
-	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
-	"
-	pkg_install() {
-		#vmove path TODO
-		vmkdir etc/profile.d
-		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
-		EOF
-	}
-}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (10 preceding siblings ...)
  2022-01-16  2:53 ` [PR PATCH] [Updated] " classabbyamp
@ 2022-01-16  2:57 ` classabbyamp
  2022-01-17 10:49 ` classabbyamp
                   ` (36 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-16  2:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2145 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✘ (`Unknown test selection: 'gtest'`) <br> 16 ✘ (`Unknown test selection: 'gtest'`) <br> 17 ✘ (`Unknown test selection: 'gtest'`) |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✘ (`Unknown test selection: 'gtest'`) <br> 16 ✘ (`Unknown test selection: 'gtest'`) <br> 17 ✘ (`Unknown test selection: 'gtest'`) |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 | 12 ✔ <br> 13 ✔ <br> 14 ✘ (2 tests fail) <br> 15 ✘ (`Unknown test selection: 'gtest'`) <br> 16 ✘ (`Unknown test selection: 'gtest'`) <br> 17 ✘ (`Unknown test selection: 'gtest'`) |
| aarch64 | ✔ | 17 | 17 |
| aarch64-musl | ✔ | 17 | 17 |
| armv7l | ✔ | 17 | 17 |
| armv6l-musl | ✔ | 17 | 17 |

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 213454 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/12] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/12] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/12] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/12] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/12] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/12] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/12] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/12] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/12] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/12] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From 81652712bd44e6ad579c4af312721a7dda5e9e14 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/12] openjdk17: TEMP

ci-skip
---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

From c30776905cf13835fa25f4bc4ed48d65e8b76217 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 21:53:23 -0500
Subject: [PATCH 12/12] openjdk17: TEMP

---
 srcpkgs/openjdk17/template | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 602730ee0519..0486ddae28eb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,4 +1,5 @@
 # Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -33,14 +34,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-depends="openjdk17-jre-${version}_${revision}"
-provides="java-environment-${version}_1"
-short_desc="OpenJDK Java Development Kit"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -166,6 +167,10 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -195,25 +200,3 @@ openjdk17-src_package() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
-
-openjdk17-jre_package() {
-	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
-	provides="java-runtime-${version}_1"
-	short_desc+=" - runtime components"
-	alternatives="
-	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
-	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
-	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
-	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
-	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
-	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
-	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
-	"
-	pkg_install() {
-		#vmove path TODO
-		vmkdir etc/profile.d
-		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
-		EOF
-	}
-}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (11 preceding siblings ...)
  2022-01-16  2:57 ` classabbyamp
@ 2022-01-17 10:49 ` classabbyamp
  2022-01-17 11:16 ` classabbyamp
                   ` (35 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 10:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1841 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✘ (2 tests fail) <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 220540 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/13] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/13] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/13] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/13] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/13] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/13] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/13] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/13] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/13] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/13] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From 81652712bd44e6ad579c4af312721a7dda5e9e14 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/13] openjdk17: TEMP

ci-skip
---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

From c30776905cf13835fa25f4bc4ed48d65e8b76217 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 21:53:23 -0500
Subject: [PATCH 12/13] openjdk17: TEMP

---
 srcpkgs/openjdk17/template | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 602730ee0519..0486ddae28eb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,4 +1,5 @@
 # Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -33,14 +34,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-depends="openjdk17-jre-${version}_${revision}"
-provides="java-environment-${version}_1"
-short_desc="OpenJDK Java Development Kit"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -166,6 +167,10 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -195,25 +200,3 @@ openjdk17-src_package() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
-
-openjdk17-jre_package() {
-	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
-	provides="java-runtime-${version}_1"
-	short_desc+=" - runtime components"
-	alternatives="
-	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
-	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
-	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
-	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
-	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
-	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
-	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
-	"
-	pkg_install() {
-		#vmove path TODO
-		vmkdir etc/profile.d
-		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
-		EOF
-	}
-}

From c58c7c6f8811babea61548f724242d283a62b7c1 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 05:48:56 -0500
Subject: [PATCH 13/13] openjdk17: TEMP

---
 .../files/musl_patches/check.patch            | 24 +++++++++++++++++++
 srcpkgs/openjdk15-bootstrap/template          | 12 ++++++++--
 srcpkgs/openjdk16-bootstrap/template          | 12 ++++++++--
 .../openjdk17/files/musl_patches/arm.patch    |  3 ++-
 srcpkgs/openjdk17/template                    | 12 ++++++++--
 srcpkgs/openjdk17/update                      |  1 +
 6 files changed, 57 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 495ded70b7c6..c34b77ab6e68 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,6 +20,7 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
  --with-version-build=${_java_ver}
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
@@ -39,8 +40,10 @@ short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
-distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
 nocross=yes
 
 # Build is still parallel, but don't use -jN.
@@ -109,3 +112,8 @@ post_install() {
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index d1ba18d56881..b17133c4e97a 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,6 +19,7 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
  --with-version-build=${_java_ver}
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
@@ -39,8 +40,10 @@ short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
-distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
 nocross=yes
 
 # Build is still parallel, but don't use -jN.
@@ -109,3 +112,8 @@ post_install() {
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
index 102428f10f33..32b4b0102a8e 100644
--- a/srcpkgs/openjdk17/files/musl_patches/arm.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -1,7 +1,8 @@
 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
 +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
-@@ -73,6 +73,18 @@
+@@ -73,7 +73,18 @@
  # include <ucontext.h>
+-# include <fpu_control.h>
  # include <asm/ptrace.h>
  
 +// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 0486ddae28eb..bac3d502d783 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -20,6 +20,7 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
  --with-version-build=${_java_ver}
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
@@ -39,8 +40,10 @@ short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
-distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
 shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
@@ -175,6 +178,11 @@ post_install() {
 	vlicense LICENSE
 }
 
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
 openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (12 preceding siblings ...)
  2022-01-17 10:49 ` classabbyamp
@ 2022-01-17 11:16 ` classabbyamp
  2022-01-17 11:23 ` classabbyamp
                   ` (34 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 11:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 222730 bytes --]

From 474242feb243c101cdef9c4d7596fbd5f46e0ad4 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 01/13] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4867fbef82e7e43f91af609a3739ddc5586bc22a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:12:34 -0500
Subject: [PATCH 02/13] New package: openjdk12-bootstrap-12.0.2+10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..31ae8415b151
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From c0b18c361b16f319187b4fa184f7d886153750f3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:23 -0500
Subject: [PATCH 03/13] New package: openjdk13-bootstrap-13.0.5.1+1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0eca86842842
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=5
+_java_patch_ver=1
+_jdk_update=1
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f0282ab7ac62e2b7f308e90c8eee3c5bd48747bd Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:13:44 -0500
Subject: [PATCH 04/13] New package: openjdk14-bootstrap-14.0.2+12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 115 ++++++
 6 files changed, 693 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..26d50f87820f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,115 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 2d00150fdf980623c1c7c4b7167de03650392f98 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:21 -0500
Subject: [PATCH 05/13] New package: openjdk15-bootstrap-15.0.3+3

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk15-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..8ea19af992fd
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cfe74dc74823d45a8ea5bb5c83156c788fc54a31 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:14:56 -0500
Subject: [PATCH 06/13] New package: openjdk16-bootstrap-16.0.2+7

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk16-bootstrap/template          | 111 ++++++
 6 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..6bdef6f9610b
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,111 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From e9eacc8c71183839c92c280618b77e7a9e646f5e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 03:17:19 -0500
Subject: [PATCH 07/13] New package: openjdk17-17.0.1+12

Co-authored-by: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk17/files/musl_patches/arm.patch    |  21 +
 .../openjdk17/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk17/template                    | 201 ++++++++++
 9 files changed, 787 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template

diff --git a/common/shlibs b/common/shlibs
index ebbd48a3d84c..a73000383c8f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4097,3 +4097,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..1d5bca529832
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,201 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=$_java_ver
+ --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -Np1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From 4c6d4273ea59f7fdb10269971f7a18f981642314 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Wed, 12 Jan 2022 16:56:36 -0500
Subject: [PATCH 08/13] openjdk17: TEMP fix musl patch flags

---
 srcpkgs/openjdk12-bootstrap/template |  2 +-
 srcpkgs/openjdk13-bootstrap/template | 11 +++++------
 srcpkgs/openjdk14-bootstrap/template |  2 +-
 srcpkgs/openjdk15-bootstrap/template |  2 +-
 srcpkgs/openjdk16-bootstrap/template |  2 +-
 srcpkgs/openjdk17/template           |  2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 31ae8415b151..813a67ac50a3 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -73,7 +73,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 0eca86842842..8c6ac7d9f94a 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,11 +1,10 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=5
-_java_patch_ver=1
-_jdk_update=1
+_java_sec_ver=4
+_jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
-_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}.${_java_patch_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk13-bootstrap
 version="${_base_version}+${_jdk_update}"
@@ -41,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=c8ff6ceda71ec75aeeda6d037205f62fb5a5f4c59a572408201b4be9f00bda03
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
 lib32disabled=yes
 nocross=yes
 
@@ -73,7 +72,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 26d50f87820f..013fb7f19a04 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 8ea19af992fd..5ce0d349f35e 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index 6bdef6f9610b..e2808a54d1d4 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -71,7 +71,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 1d5bca529832..3093f71aed56 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -127,7 +127,7 @@ post_patch() {
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
-			patch -Np1 -i "$f"
+			patch -lNp1 -i "$f"
 		done
 	fi
 }

From 92eace1b02b0cb7e3d54e160893fbf5751f7f73e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 13 Jan 2022 21:59:21 -0500
Subject: [PATCH 09/13] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template          |   4 +-
 srcpkgs/openjdk14-bootstrap/template          |   4 +-
 .../files/musl_patches/build.patch            |  53 +----
 srcpkgs/openjdk15-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../files/musl_patches/build.patch            | 212 +-----------------
 srcpkgs/openjdk16-bootstrap/template          |   4 +-
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk17/files/musl_patches/build.patch  | 212 +-----------------
 srcpkgs/openjdk17/template                    |   6 +-
 10 files changed, 28 insertions(+), 491 deletions(-)
 delete mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk17/files/musl_patches/aarch64.patch

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 8c6ac7d9f94a..32acd32ba2e1 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 013fb7f19a04..24e4315c7eae 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..503df469b584 100644
--- a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -18,8 +18,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -127,13 +127,13 @@
      assert(*prev_ptr == cur, "just checking");
 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp
 +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
    #endif
  
    #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
 -         " for " OS "-" CPU FLOAT_ARCH_STR \
 +         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
           " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
  
 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
@@ -194,9 +194,9 @@
  #define ISNAND(d) isnan(d)
  #elif defined(_AIX)
  #include <math.h>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
-@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
  
@@ -247,45 +247,6 @@
  #elif defined(_AIX)
    #include <pthread.h>
    /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 5ce0d349f35e..495ded70b7c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,8 +20,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index e2808a54d1d4..d1ba18d56881 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,8 +19,8 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
diff --git a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch b/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk17/files/musl_patches/aarch64.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
-@@ -74,7 +74,6 @@
- # include <pwd.h>
- # include <poll.h>
- # include <ucontext.h>
--# include <fpu_control.h>
- 
- #define REG_FP 29
- #define REG_LR 30
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
index 60dfdec30abc..1158babcd96d 100644
--- a/srcpkgs/openjdk17/files/musl_patches/build.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -1,13 +1,3 @@
---- a/make/ReleaseFile.gmk
-+++ b/make/ReleaseFile.gmk
-@@ -53,6 +53,7 @@ define create-info-file
-   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
-   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
-   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
-+  $(call info-file-item, "LIBC", "musl")
- endef
- 
- # Param 1 - The file containing the MODULES list
 --- a/make/hotspot/lib/CompileJvm.gmk
 +++ b/make/hotspot/lib/CompileJvm.gmk
 @@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
@@ -18,8 +8,8 @@
      #
  
  ################################################################################
---- a/make/lib/CoreLibraries.gmk
-+++ b/make/lib/CoreLibraries.gmk
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
 @@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
  endif
  
@@ -30,35 +20,6 @@
    LIBJLI_EXTRA_FILES += \
 --- a/src/hotspot/os/linux/os_linux.cpp
 +++ b/src/hotspot/os/linux/os_linux.cpp
-@@ -102,7 +102,6 @@
- # include <string.h>
- # include <syscall.h>
- # include <sys/sysinfo.h>
--# include <gnu/libc-version.h>
- # include <sys/ipc.h>
- # include <sys/shm.h>
- # include <link.h>
-@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
- // detecting pthread library
- 
- void os::Linux::libpthread_init() {
-+#if !defined(__GLIBC__) && !defined(__UCLIBC__)
-+  // Hard code Alpine Linux supported musl compatible settings
-+  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
-+  os::Linux::set_glibc_version("glibc 2.9");
-+  os::Linux::set_libpthread_version("NPTL");
-+#else
-   // Save glibc and pthread version strings.
- #if !defined(_CS_GNU_LIBC_VERSION) || \
-     !defined(_CS_GNU_LIBPTHREAD_VERSION)
-@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
-   str = (char *)malloc(n, mtInternal);
-   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-   os::Linux::set_libpthread_version(str);
-+#endif
- }
- 
- /////////////////////////////////////////////////////////////////////////////
 @@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
  extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
  extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -125,47 +86,6 @@
    ScratchBlock  *cur = *prev_ptr;
    while (cur) {
      assert(*prev_ptr == cur, "just checking");
---- a/src/hotspot/share/runtime/abstract_vm_version.cpp
-+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
-@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
-   #endif
- 
-   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
--         " for " OS "-" CPU FLOAT_ARCH_STR \
-+         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
-          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
-          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
- 
---- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
-@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
- #elif defined(__APPLE__)
- inline int g_isnan(double f) { return isnan(f); }
- #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
--inline int g_isnan(float  f) { return isnanf(f); }
-+inline int g_isnan(float  f) { return isnan(f); }
- inline int g_isnan(double f) { return isnan(f); }
- #else
- #error "missing platform-specific definition here"
---- a/src/java.base/linux/native/libnet/linux_close.c
-+++ b/src/java.base/linux/native/libnet/linux_close.c
-@@ -60,7 +60,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
-@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
-     /*
-      * Setup the signal handler
-      */
-+    sigWakeup = SIGRTMAX - 2;
-     sa.sa_handler = sig_wakeup;
-     sa.sa_flags   = 0;
-     sigemptyset(&sa.sa_mask);
 --- a/src/java.base/unix/native/libjava/childproc.c
 +++ b/src/java.base/unix/native/libjava/childproc.c
 @@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
@@ -183,19 +103,8 @@
      }
  
      if (*file == '\0') {
---- a/src/java.base/unix/native/libjava/jdk_util_md.h
-+++ b/src/java.base/unix/native/libjava/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>
---- a/src/java.base/unix/native/libjli/java_md_solinux.c
-+++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
 @@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
      char *dmllp = NULL;
      char *p; /* a utility pointer */
@@ -236,56 +145,6 @@
  #ifdef AIX
      /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
      return JNI_TRUE;
---- a/src/java.base/unix/native/libnio/ch/NativeThread.c
-+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
-@@ -36,7 +36,7 @@
- #ifdef __linux__
-   #include <pthread.h>
-   /* Also defined in net/linux_close.c */
--  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
-+  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
- #elif defined(_AIX)
-   #include <pthread.h>
-   /* Also defined in net/aix_close.c */
---- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-+++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
-@@ -27,9 +27,6 @@
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
--#ifdef __linux__
--#include <execinfo.h>
--#endif
- 
- #include <jvm.h>
- #include <jni.h>
-@@ -780,26 +777,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;
 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
 @@ -35,15 +35,15 @@
@@ -308,65 +167,4 @@
 +    #define strdup do_not_use_this_interface_strdup
  #endif
  
- #include "log_messages.h"
---- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
-@@ -33,6 +33,7 @@
- 
- #include <assert.h>
- #include <jni.h>
-+#include <jvm.h>
- #include <alloca.h>
- #include <signal.h>
- #include <string.h>
-@@ -91,6 +92,20 @@ void set_signal_handler() {
-   }
- }
- 
-+int get_java_stacksize () {
-+  size_t stacksize;
-+  pthread_attr_t attr;
-+  JDK1_1InitArgs jdk_args;
-+
-+  jdk_args.version = JNI_VERSION_1_1;
-+  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
-+  if (jdk_args.javaStackSize <= 0) {
-+    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
-+    exit(7);
-+  }
-+  return jdk_args.javaStackSize;
-+}
-+
- void *run_java_overflow (void *p) {
-   JNIEnv *env;
-   jclass class_id;
-@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
-     exit(7);
-   }
- 
-+  int stack_size = get_java_stacksize();
-   pthread_t thr;
-+  pthread_attr_t thread_attr;
-+
-+  pthread_attr_init(&thread_attr);
-+  pthread_attr_setstacksize(&thread_attr, stack_size);
- 
-   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
-     printf("\nTesting JAVA_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_java_overflow, NULL);
-+
-+    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
-@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
-     printf("\nTesting NATIVE_OVERFLOW\n");
- 
-     printf("Testing stack guard page behaviour for other thread\n");
--    pthread_create (&thr, NULL, run_native_overflow, NULL);
-+    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
-     pthread_join (thr, NULL);
- 
-     printf("Testing stack guard page behaviour for initial thread\n");
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 3093f71aed56..d435782703a6 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -19,14 +19,14 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=$_java_ver
- --with-jobs=$XBPS_ORIG_MAKEJOBS
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
  --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
 make_build_args="images $(vopt_if docs docs)"
-make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
 make_check_target="test-hotspot-gtest"
 hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
  libressl zlib-devel which make-ca"

From e707521ab4a7a70b9f5db50711a5908207f39802 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Fri, 14 Jan 2022 16:59:13 -0500
Subject: [PATCH 10/13] openjdk17: TEMP

---
 srcpkgs/openjdk13-bootstrap/template | 4 ++--
 srcpkgs/openjdk17/template           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 32acd32ba2e1..01c5c45883e8 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -1,7 +1,7 @@
 # Template file for 'openjdk13-bootstrap'
 _java_ver=13
 _java_min_ver=0
-_java_sec_ver=4
+_java_sec_ver=2
 _jdk_update=8
 _jdk_home="usr/lib/jvm/openjdk${_java_ver}"
 _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
@@ -40,7 +40,7 @@ maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="https://openjdk.java.net/"
 distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
 lib32disabled=yes
 nocross=yes
 
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index d435782703a6..e3fe9a7679c1 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=1
+revision=0
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors

From 81652712bd44e6ad579c4af312721a7dda5e9e14 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 12:08:49 -0500
Subject: [PATCH 11/13] openjdk17: TEMP

ci-skip
---
 srcpkgs/openjdk17/template | 116 +++++++++++++++++++++----------------
 1 file changed, 67 insertions(+), 49 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index e3fe9a7679c1..602730ee0519 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -8,7 +8,7 @@ _base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
 
 pkgname=openjdk17
 version="${_base_version}+${_jdk_update}"
-revision=0
+revision=1
 wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
 build_style=gnu-configure
 configure_args="--disable-warnings-as-errors
@@ -33,14 +33,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="openjdk17-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -74,46 +74,46 @@ else
 fi
 
 alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk17/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk17/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk17/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk17/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk17/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk17/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk17/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk17/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk17/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk17/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk17/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk17/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk17/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk17/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk17/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk17/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk17/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk17/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk17/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk17/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk17/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk17/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk17/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk17/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk17/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk17/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk17/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk17/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk17/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk17/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk17/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk17/bin/unpack200
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -166,10 +166,6 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -178,7 +174,7 @@ openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- documentation"
+	short_desc+=" - documentation"
 	pkg_install() {
 		cd ${wrksrc}
 		if [ "$build_option_docs" ]; then
@@ -194,8 +190,30 @@ openjdk17-src_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc+=" -- sources"
+	short_desc+=" - source code"
 	pkg_install() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	provides="java-runtime-${version}_1"
+	short_desc+=" - runtime components"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
+	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
+	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
+	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
+	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
+	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
+	"
+	pkg_install() {
+		#vmove path TODO
+		vmkdir etc/profile.d
+		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
+		EOF
+	}
+}

From c30776905cf13835fa25f4bc4ed48d65e8b76217 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Sat, 15 Jan 2022 21:53:23 -0500
Subject: [PATCH 12/13] openjdk17: TEMP

---
 srcpkgs/openjdk17/template | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 602730ee0519..0486ddae28eb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,4 +1,5 @@
 # Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -33,14 +34,14 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-depends="openjdk17-jre-${version}_${revision}"
-provides="java-environment-${version}_1"
-short_desc="OpenJDK Java Development Kit"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
 distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
 checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -166,6 +167,10 @@ post_install() {
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
@@ -195,25 +200,3 @@ openjdk17-src_package() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
-
-openjdk17-jre_package() {
-	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
-	provides="java-runtime-${version}_1"
-	short_desc+=" - runtime components"
-	alternatives="
-	 java:/usr/bin/java:/${_jdk_home}/jre/bin/java
-	 java:/usr/bin/jjs:/${_jdk_home}/jre/bin/jjs
-	 java:/usr/bin/keytool:/${_jdk_home}/jre/bin/keytool
-	 java:/usr/bin/pack200:/${_jdk_home}/jre/bin/pack200
-	 java:/usr/bin/rmid:/${_jdk_home}/jre/bin/rmid
-	 java:/usr/bin/rmiregistry:/${_jdk_home}/jre/bin/rmiregistry
-	 java:/usr/bin/unpack200:/${_jdk_home}/jre/bin/unpack200
-	"
-	pkg_install() {
-		#vmove path TODO
-		vmkdir etc/profile.d
-		cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-		export JAVA_HOME=\${JAVA_HOME=/$_jdk_home/jre}
-		EOF
-	}
-}

From 47d3e5f6dba9cba36e91ca39bf3f7c2823f1ee16 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 05:48:56 -0500
Subject: [PATCH 13/13] openjdk17: TEMP

---
 .../files/i686_patches/JDK-8238909.patch      | 30 +++++++++++++++++++
 srcpkgs/openjdk14-bootstrap/template          |  9 ++++++
 .../files/musl_patches/check.patch            | 24 +++++++++++++++
 srcpkgs/openjdk15-bootstrap/template          | 12 ++++++--
 srcpkgs/openjdk16-bootstrap/template          | 12 ++++++--
 .../openjdk17/files/musl_patches/arm.patch    |  3 +-
 srcpkgs/openjdk17/template                    | 12 ++++++--
 srcpkgs/openjdk17/update                      |  1 +
 8 files changed, 96 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 24e4315c7eae..4f93cce4fa22 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -68,6 +68,15 @@ post_extract() {
 }
 
 post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*) 
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		for f in "${FILESDIR}"/musl_patches/*.patch; do
 			msg_normal "Applying ${f#$FILESDIR/}\n"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index 495ded70b7c6..c34b77ab6e68 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -20,6 +20,7 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
  --with-version-build=${_java_ver}
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
@@ -39,8 +40,10 @@ short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
-distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
 nocross=yes
 
 # Build is still parallel, but don't use -jN.
@@ -109,3 +112,8 @@ post_install() {
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index d1ba18d56881..b17133c4e97a 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -19,6 +19,7 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
  --with-version-build=${_java_ver}
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
@@ -39,8 +40,10 @@ short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
-distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
 nocross=yes
 
 # Build is still parallel, but don't use -jN.
@@ -109,3 +112,8 @@ post_install() {
 	vlicense ASSEMBLY_EXCEPTION
 	vlicense LICENSE
 }
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
index 102428f10f33..32b4b0102a8e 100644
--- a/srcpkgs/openjdk17/files/musl_patches/arm.patch
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -1,7 +1,8 @@
 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
 +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
-@@ -73,6 +73,18 @@
+@@ -73,7 +73,18 @@
  # include <ucontext.h>
+-# include <fpu_control.h>
  # include <asm/ptrace.h>
  
 +// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index 0486ddae28eb..bac3d502d783 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -20,6 +20,7 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
  --with-version-build=${_java_ver}
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
  --with-vendor-name=Void
@@ -39,8 +40,10 @@ short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
 homepage="http://openjdk.java.net/"
-distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
 shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
@@ -175,6 +178,11 @@ post_install() {
 	vlicense LICENSE
 }
 
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
 openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (13 preceding siblings ...)
  2022-01-17 11:16 ` classabbyamp
@ 2022-01-17 11:23 ` classabbyamp
  2022-01-17 11:27 ` classabbyamp
                   ` (33 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 11:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 158328 bytes --]

From ced3a79f676e09a3f2298eb45ebc1e417c97e0d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/7] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From c6637169a99f1641c4d47335d7b434e43afb243c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/7] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a5a86c535e46b9e5cd504cb5cb169e99f3b6d179 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/7] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f2564e20f337749d3701e746d7ed975eef1c5dff Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:19:17 -0500
Subject: [PATCH 4/7] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..4f93cce4fa22
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*) 
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6f204eecdfcd492ee3c7de34076c9e46035240bf Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:19:32 -0500
Subject: [PATCH 5/7] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From ad1bccec16e8ad2497ab4cf42289c120ac779dd6 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:19:46 -0500
Subject: [PATCH 6/7] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From c86b8315d879181badbc266c4ed1002ecd694d23 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:20:01 -0500
Subject: [PATCH 7/7] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index b07e14379e28..2a3432da7229 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4098,3 +4098,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (14 preceding siblings ...)
  2022-01-17 11:23 ` classabbyamp
@ 2022-01-17 11:27 ` classabbyamp
  2022-01-17 15:49 ` EliteTK
                   ` (32 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 11:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

[WIP] New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 158327 bytes --]

From ced3a79f676e09a3f2298eb45ebc1e417c97e0d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/7] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From c6637169a99f1641c4d47335d7b434e43afb243c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/7] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a5a86c535e46b9e5cd504cb5cb169e99f3b6d179 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/7] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From eea4fa5cf42de8ed764cfa3478dc565a14b6807f Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:25:54 -0500
Subject: [PATCH 4/7] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..837375b36472
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From dc0ae346661fb95bf5bbe2e2cfe1716225f0acac Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:19 -0500
Subject: [PATCH 5/7] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 9635806ff10c28370610643ac8d08709ecfea660 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:32 -0500
Subject: [PATCH 6/7] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 74c417edbfce4d0efb9694bd1b71adc413b57127 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:59 -0500
Subject: [PATCH 7/7] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index b07e14379e28..2a3432da7229 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4098,3 +4098,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (15 preceding siblings ...)
  2022-01-17 11:27 ` classabbyamp
@ 2022-01-17 15:49 ` EliteTK
  2022-01-17 17:19 ` classabbyamp
                   ` (31 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: EliteTK @ 2022-01-17 15:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 699 bytes --]

New comment by EliteTK on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014680423

Comment:
The XBPS_MAKEJOBS -> XBPS_ORIG_MAKEJOBS trick doesn't appear to work. I haven't quite figured out why yet but:

* If I build openjdk17 (indirectly building openjdk12-bootstrap) the configure gets passed --with-jobs=1.
* If I explicitly set XBPS_ORIG_MAKEJOBS when building openjdk17 this is still the case.
* If I explicitly build openjdk12-bootstrap the issue persists.
* If I explicitly build openjdk12-bootstrap with XBPS_ORIG_MAKEJOBS the issue persists.

I will just hardcode a sensible value, build, and chip in by testing this on x86_64 a bit.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (16 preceding siblings ...)
  2022-01-17 15:49 ` EliteTK
@ 2022-01-17 17:19 ` classabbyamp
  2022-01-17 17:28 ` classabbyamp
                   ` (30 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 17:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014754409

Comment:
@EliteTK you only need to set the standard `XBPS_MAKEJOBS` for it to work. `XBPS_ORIG_MAKEJOBS` shouldn't be changed manually, because if `XBPS_MAKEJOBS` is unset, `XBPS_ORIG_MAKEJOBS` will be set to 1 within xbps-src

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (17 preceding siblings ...)
  2022-01-17 17:19 ` classabbyamp
@ 2022-01-17 17:28 ` classabbyamp
  2022-01-17 17:34 ` classabbyamp
                   ` (29 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 17:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014754409

Comment:
@EliteTK you only need to set the standard `XBPS_MAKEJOBS` for it to work. `XBPS_ORIG_MAKEJOBS` shouldn't be changed manually, because if `XBPS_MAKEJOBS` is unset, `XBPS_ORIG_MAKEJOBS` will be set to 1 within xbps-src, and if it is set, the value is transferred automatically.

(personally I set `XBPS_MAKEJOBS` in my shell rcfile)

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (18 preceding siblings ...)
  2022-01-17 17:28 ` classabbyamp
@ 2022-01-17 17:34 ` classabbyamp
  2022-01-17 18:36 ` EliteTK
                   ` (28 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 17:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014768122

Comment:
sidenote for other reviewers: should something be added to Manual.md about `XBPS_ORIG_MAKEJOBS`?

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (19 preceding siblings ...)
  2022-01-17 17:34 ` classabbyamp
@ 2022-01-17 18:36 ` EliteTK
  2022-01-17 20:15 ` classabbyamp
                   ` (27 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: EliteTK @ 2022-01-17 18:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

New comment by EliteTK on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014805382

Comment:
Yes, what I meant is that it didn’t work regardless of if I just set XBPS_MAKEJOBS or if I set both.

> On 17 Jan 2022, at 17:20, classabbyamp ***@***.***> wrote:
> 
> 
> @EliteTK you only need to set the standard XBPS_MAKEJOBS for it to work. XBPS_ORIG_MAKEJOBS shouldn't be changed manually, because if XBPS_MAKEJOBS is unset, XBPS_ORIG_MAKEJOBS will be set to 1 within xbps-src
> 
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> Triage notifications on the go with GitHub Mobile for iOS or Android. 
> You are receiving this because you were mentioned.


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (20 preceding siblings ...)
  2022-01-17 18:36 ` EliteTK
@ 2022-01-17 20:15 ` classabbyamp
  2022-01-17 20:51 ` classabbyamp
                   ` (26 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 20:15 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 607 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014859007

Comment:
I cloned a fresh copy of void-packages and tried it:
```
$ echo $XBPS_MAKEJOBS
12
$ ./xbps-src configure openjdk12-bootstrap
...
checking for number of cores... 12
checking for memory size... 32019 MB
...
Build performance summary:
* Cores to use:   1
* Memory limit:   32019 MB
```

That's very strange; when I was running my builds locally, I got 12 cores in both places of the configure output. Do you get the correct number in the first spot?

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (21 preceding siblings ...)
  2022-01-17 20:15 ` classabbyamp
@ 2022-01-17 20:51 ` classabbyamp
  2022-01-17 22:48 ` motorto
                   ` (25 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 20:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014878030

Comment:
seems setting `XBPS_MAKEJOBS` in your environment doesn't work, you have to either `echo 'XBPS_MAKEJOBS=n' >> etc/conf` or use the `-j n` flag of xbps-src. Should not be an issue on the builders

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [WIP] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (22 preceding siblings ...)
  2022-01-17 20:51 ` classabbyamp
@ 2022-01-17 22:48 ` motorto
  2022-01-17 22:51 ` classabbyamp
                   ` (24 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: motorto @ 2022-01-17 22:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 245 bytes --]

New comment by motorto on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014935306

Comment:
@classabbyamp  Anything I can do to help ? It seems that the work is mostly done, but just making sure 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (23 preceding siblings ...)
  2022-01-17 22:48 ` motorto
@ 2022-01-17 22:51 ` classabbyamp
  2022-01-18  9:33 ` EliteTK
                   ` (23 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-01-17 22:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1014936226

Comment:
If you'd like, you can try to build it on your machine, but other than that there's not much to do I think

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (24 preceding siblings ...)
  2022-01-17 22:51 ` classabbyamp
@ 2022-01-18  9:33 ` EliteTK
  2022-01-18  9:35 ` EliteTK
                   ` (22 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: EliteTK @ 2022-01-18  9:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]

New comment by EliteTK on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1015228417

Comment:
I should chip in to say that I tested this on x86 (building and running a Java application for a few hours) and it seemed to work fine. Haven’t tested the D part of the JDK though. 




^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (25 preceding siblings ...)
  2022-01-18  9:33 ` EliteTK
@ 2022-01-18  9:35 ` EliteTK
  2022-01-18  9:36 ` EliteTK
                   ` (21 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: EliteTK @ 2022-01-18  9:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

New comment by EliteTK on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1015228417

Comment:
I should chip in to say that I tested this on x86_64 (building and running a Java application for a few hours) and it seemed to work fine. Haven’t tested the D part of the JDK though. 




^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (26 preceding siblings ...)
  2022-01-18  9:35 ` EliteTK
@ 2022-01-18  9:36 ` EliteTK
  2022-02-01 23:01 ` [PR PATCH] [Updated] " classabbyamp
                   ` (20 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: EliteTK @ 2022-01-18  9:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

New comment by EliteTK on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1015228417

Comment:
I should chip in to say that I tested this on x86_64 (building the package and running a Java application for a few hours) and it seemed to work fine. Haven’t tested the D part of the JDK though. 




^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (27 preceding siblings ...)
  2022-01-18  9:36 ` EliteTK
@ 2022-02-01 23:01 ` classabbyamp
  2022-02-01 23:11 ` classabbyamp
                   ` (19 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-01 23:01 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 169347 bytes --]

From ced3a79f676e09a3f2298eb45ebc1e417c97e0d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From c6637169a99f1641c4d47335d7b434e43afb243c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a5a86c535e46b9e5cd504cb5cb169e99f3b6d179 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From eea4fa5cf42de8ed764cfa3478dc565a14b6807f Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:25:54 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..837375b36472
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From dc0ae346661fb95bf5bbe2e2cfe1716225f0acac Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:19 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 9635806ff10c28370610643ac8d08709ecfea660 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:32 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 74c417edbfce4d0efb9694bd1b71adc413b57127 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:59 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index b07e14379e28..2a3432da7229 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4098,3 +4098,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

From c5a675242e18c1d5d295bddee1a50a76fd074cdc Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 1 Feb 2022 18:00:37 -0500
Subject: [PATCH 8/8] openjdk17: TEMP

---
 srcpkgs/openjdk12-bootstrap/template |  9 +++-
 srcpkgs/openjdk13-bootstrap/template |  9 +++-
 srcpkgs/openjdk14-bootstrap/template |  9 +++-
 srcpkgs/openjdk15-bootstrap/template |  9 +++-
 srcpkgs/openjdk16-bootstrap/template |  9 +++-
 srcpkgs/openjdk17-jre                |  1 +
 srcpkgs/openjdk17/template           | 63 +++++++++++++++++++---------
 7 files changed, 84 insertions(+), 25 deletions(-)
 create mode 120000 srcpkgs/openjdk17-jre

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 813a67ac50a3..02358e4119ef 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 01c5c45883e8..0dbf71338220 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 837375b36472..7df9faf55b71 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -60,6 +63,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index c34b77ab6e68..488768dbf2c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -21,8 +21,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index b17133c4e97a..53b29eb6c4ef 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index bac3d502d783..20749b859568 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,5 +1,4 @@
 # Template file for 'openjdk17'
-# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -21,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -35,6 +37,7 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
+depends="openjdk${_java_ver}-jre-${version}_${revision}"
 provides="java-environment-${version}_1 java-runtime-${version}_1"
 short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
@@ -44,11 +47,11 @@ distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.ta
  https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
 checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
  9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
 build_options="docs"
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
 
 # no hotspot JIT for ppc32
 case "$XBPS_TARGET_MACHINE" in
@@ -77,16 +80,16 @@ else
 	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 alternatives="
  java:/usr/bin/java:/${_jdk_home}/bin/java
- java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
- java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 
- jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
  jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
  jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
  jdk:/usr/bin/java:/${_jdk_home}/bin/java
@@ -98,13 +101,14 @@ alternatives="
  jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
  jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
  jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
  jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
  jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
- jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
  jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
  jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
  jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
  jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
  jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
  jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
@@ -112,12 +116,8 @@ alternatives="
  jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
  jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
  jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
- jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
  jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
- jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -164,18 +164,12 @@ do_configure() {
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/lib/bin
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	vmkdir $_jdk_home/lib/security
 	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
-	vlicense ASSEMBLY_EXCEPTION
-	vlicense LICENSE
 }
 
 do_clean() {
@@ -208,3 +202,32 @@ openjdk17-src_package() {
 		vmove "$_jdk_home/lib/src.zip"
 	}
 }
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (28 preceding siblings ...)
  2022-02-01 23:01 ` [PR PATCH] [Updated] " classabbyamp
@ 2022-02-01 23:11 ` classabbyamp
  2022-02-03 19:13 ` classabbyamp
                   ` (18 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-01 23:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 169408 bytes --]

From ced3a79f676e09a3f2298eb45ebc1e417c97e0d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From c6637169a99f1641c4d47335d7b434e43afb243c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a5a86c535e46b9e5cd504cb5cb169e99f3b6d179 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From eea4fa5cf42de8ed764cfa3478dc565a14b6807f Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:25:54 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..837375b36472
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From dc0ae346661fb95bf5bbe2e2cfe1716225f0acac Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:19 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 9635806ff10c28370610643ac8d08709ecfea660 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:32 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 74c417edbfce4d0efb9694bd1b71adc413b57127 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:59 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index b07e14379e28..2a3432da7229 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4098,3 +4098,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

From 980cdc695d04e41eedcdcef8db747e8a52d94833 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 1 Feb 2022 18:00:37 -0500
Subject: [PATCH 8/8] openjdk17: TEMP

---
 srcpkgs/openjdk12-bootstrap/template |  9 +++-
 srcpkgs/openjdk13-bootstrap/template |  9 +++-
 srcpkgs/openjdk14-bootstrap/template |  9 +++-
 srcpkgs/openjdk15-bootstrap/template |  9 +++-
 srcpkgs/openjdk16-bootstrap/template |  9 +++-
 srcpkgs/openjdk17-jre                |  1 +
 srcpkgs/openjdk17/template           | 66 +++++++++++++++++++---------
 7 files changed, 86 insertions(+), 26 deletions(-)
 create mode 120000 srcpkgs/openjdk17-jre

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 813a67ac50a3..02358e4119ef 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 01c5c45883e8..0dbf71338220 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 837375b36472..7df9faf55b71 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -60,6 +63,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index c34b77ab6e68..488768dbf2c6 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -21,8 +21,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index b17133c4e97a..53b29eb6c4ef 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index bac3d502d783..5b8b801513cb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,5 +1,4 @@
 # Template file for 'openjdk17'
-# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -21,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -35,7 +37,8 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
@@ -44,7 +47,6 @@ distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.ta
  https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
 checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
  9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -77,16 +79,16 @@ else
 	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 alternatives="
  java:/usr/bin/java:/${_jdk_home}/bin/java
- java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
- java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 
- jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
  jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
  jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
  jdk:/usr/bin/java:/${_jdk_home}/bin/java
@@ -98,13 +100,14 @@ alternatives="
  jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
  jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
  jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
  jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
  jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
- jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
  jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
  jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
  jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
  jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
  jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
  jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
@@ -112,12 +115,8 @@ alternatives="
  jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
  jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
  jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
- jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
  jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
- jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -164,18 +163,12 @@ do_configure() {
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/lib/bin
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	vmkdir $_jdk_home/lib/security
 	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
-	vlicense ASSEMBLY_EXCEPTION
-	vlicense LICENSE
 }
 
 do_clean() {
@@ -183,6 +176,37 @@ do_clean() {
 	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
 }
 
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
 openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (29 preceding siblings ...)
  2022-02-01 23:11 ` classabbyamp
@ 2022-02-03 19:13 ` classabbyamp
  2022-02-03 19:15 ` classabbyamp
                   ` (17 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-03 19:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 171549 bytes --]

From ced3a79f676e09a3f2298eb45ebc1e417c97e0d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From c6637169a99f1641c4d47335d7b434e43afb243c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a5a86c535e46b9e5cd504cb5cb169e99f3b6d179 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From eea4fa5cf42de8ed764cfa3478dc565a14b6807f Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:25:54 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..837375b36472
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From dc0ae346661fb95bf5bbe2e2cfe1716225f0acac Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:19 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 9635806ff10c28370610643ac8d08709ecfea660 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:32 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 74c417edbfce4d0efb9694bd1b71adc413b57127 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:59 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index b07e14379e28..2a3432da7229 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4098,3 +4098,9 @@ libkmailconfirmbeforedeleting.so.5 kdepim-addons-21.08.3_1
 libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

From ed4aaf27789696a6871f44860bc36253a0bc9f58 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 1 Feb 2022 18:00:37 -0500
Subject: [PATCH 8/8] openjdk17: TEMP

---
 srcpkgs/openjdk12-bootstrap/template | 11 ++++-
 srcpkgs/openjdk13-bootstrap/template | 30 ++++++++++++-
 srcpkgs/openjdk14-bootstrap/template | 11 ++++-
 srcpkgs/openjdk15-bootstrap/template | 11 ++++-
 srcpkgs/openjdk16-bootstrap/template | 11 ++++-
 srcpkgs/openjdk17-jre                |  1 +
 srcpkgs/openjdk17/template           | 66 +++++++++++++++++++---------
 7 files changed, 110 insertions(+), 31 deletions(-)
 create mode 120000 srcpkgs/openjdk17-jre

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 813a67ac50a3..eeb928af8ac1 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 
@@ -109,7 +116,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 01c5c45883e8..fac7043b6439 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -107,8 +114,27 @@ do_configure() {
 		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
 }
 
+do_build() {
+	for _try in 1 2 3; do
+		msg_normal "Attempt $_try ...\n"
+
+		# adapted from build style
+		: ${make_cmd:=make}
+
+		export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
+		${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} && break
+		# end adapted from build style
+
+		if [ $_try -lt 3 ]; then
+			msg_warn "Build failed, retrying ...\n"
+		else
+			msg_warn "Build failed, out of attempts\n"
+		fi
+	done
+}
+
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 837375b36472..dc61ad9c466f 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -60,6 +63,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -116,7 +123,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index c34b77ab6e68..a6d65a6b4300 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -21,8 +21,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -106,7 +113,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index b17133c4e97a..085e9290cfeb 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -106,7 +113,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index bac3d502d783..5b8b801513cb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,5 +1,4 @@
 # Template file for 'openjdk17'
-# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -21,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -35,7 +37,8 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
@@ -44,7 +47,6 @@ distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.ta
  https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
 checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
  9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -77,16 +79,16 @@ else
 	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 alternatives="
  java:/usr/bin/java:/${_jdk_home}/bin/java
- java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
- java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 
- jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
  jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
  jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
  jdk:/usr/bin/java:/${_jdk_home}/bin/java
@@ -98,13 +100,14 @@ alternatives="
  jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
  jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
  jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
  jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
  jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
- jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
  jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
  jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
  jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
  jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
  jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
  jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
@@ -112,12 +115,8 @@ alternatives="
  jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
  jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
  jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
- jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
  jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
- jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -164,18 +163,12 @@ do_configure() {
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/lib/bin
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	vmkdir $_jdk_home/lib/security
 	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
-	vlicense ASSEMBLY_EXCEPTION
-	vlicense LICENSE
 }
 
 do_clean() {
@@ -183,6 +176,37 @@ do_clean() {
 	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
 }
 
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
 openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (30 preceding siblings ...)
  2022-02-03 19:13 ` classabbyamp
@ 2022-02-03 19:15 ` classabbyamp
  2022-02-03 19:59 ` classabbyamp
                   ` (16 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-03 19:15 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 171523 bytes --]

From 541d761098770ac9d08b935032b0ebf2b11935c0 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From cee8baeb34cae950b62c40c49528e6708d35fa6c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 4450e81aba78c92bdee35d3ccda7d7167249f321 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cde58beac3a2fa62a8229c1cf6697ac154b4fd29 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:25:54 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..837375b36472
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 7cd40017af3f630a4c05d29a389c86cf4d9119be Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:19 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 83d2139e6151014fb31396c21a892a4de03892a7 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:32 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From d15c9c04abc6a00cffae7e880f93bd5716d1e5fa Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:59 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index 76df17e8ba13..42f8a4e1e4b5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4102,3 +4102,9 @@ libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
 libdeflate.so.0 libdeflate-1.8_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

From 6466fa43f61b58cd30651c50fb8f863d12b03a80 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 1 Feb 2022 18:00:37 -0500
Subject: [PATCH 8/8] openjdk17: TEMP

---
 srcpkgs/openjdk12-bootstrap/template | 11 ++++-
 srcpkgs/openjdk13-bootstrap/template | 30 ++++++++++++-
 srcpkgs/openjdk14-bootstrap/template | 11 ++++-
 srcpkgs/openjdk15-bootstrap/template | 11 ++++-
 srcpkgs/openjdk16-bootstrap/template | 11 ++++-
 srcpkgs/openjdk17-jre                |  1 +
 srcpkgs/openjdk17/template           | 66 +++++++++++++++++++---------
 7 files changed, 110 insertions(+), 31 deletions(-)
 create mode 120000 srcpkgs/openjdk17-jre

diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 813a67ac50a3..eeb928af8ac1 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 
@@ -109,7 +116,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 01c5c45883e8..fac7043b6439 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -107,8 +114,27 @@ do_configure() {
 		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
 }
 
+do_build() {
+	for _try in 1 2 3; do
+		msg_normal "Attempt $_try ...\n"
+
+		# adapted from build style
+		: ${make_cmd:=make}
+
+		export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
+		${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} && break
+		# end adapted from build style
+
+		if [ $_try -lt 3 ]; then
+			msg_warn "Build failed, retrying ...\n"
+		else
+			msg_warn "Build failed, out of attempts\n"
+		fi
+	done
+}
+
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 837375b36472..dc61ad9c466f 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -60,6 +63,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -116,7 +123,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index c34b77ab6e68..a6d65a6b4300 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -21,8 +21,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -106,7 +113,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index b17133c4e97a..085e9290cfeb 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -106,7 +113,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index bac3d502d783..5b8b801513cb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,5 +1,4 @@
 # Template file for 'openjdk17'
-# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -21,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -35,7 +37,8 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
@@ -44,7 +47,6 @@ distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.ta
  https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
 checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
  9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -77,16 +79,16 @@ else
 	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 alternatives="
  java:/usr/bin/java:/${_jdk_home}/bin/java
- java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
- java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 
- jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
  jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
  jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
  jdk:/usr/bin/java:/${_jdk_home}/bin/java
@@ -98,13 +100,14 @@ alternatives="
  jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
  jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
  jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
  jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
  jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
- jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
  jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
  jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
  jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
  jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
  jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
  jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
@@ -112,12 +115,8 @@ alternatives="
  jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
  jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
  jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
- jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
  jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
- jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -164,18 +163,12 @@ do_configure() {
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/lib/bin
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	vmkdir $_jdk_home/lib/security
 	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
-	vlicense ASSEMBLY_EXCEPTION
-	vlicense LICENSE
 }
 
 do_clean() {
@@ -183,6 +176,37 @@ do_clean() {
 	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
 }
 
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
 openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (31 preceding siblings ...)
  2022-02-03 19:15 ` classabbyamp
@ 2022-02-03 19:59 ` classabbyamp
  2022-02-03 20:03 ` classabbyamp
                   ` (15 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-03 19:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 172483 bytes --]

From 541d761098770ac9d08b935032b0ebf2b11935c0 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From cee8baeb34cae950b62c40c49528e6708d35fa6c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:37 -0500
Subject: [PATCH 2/8] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 117 ++++++
 6 files changed, 713 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..813a67ac50a3
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,117 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 4450e81aba78c92bdee35d3ccda7d7167249f321 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:18:53 -0500
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 116 ++++++
 6 files changed, 712 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..01c5c45883e8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,116 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From cde58beac3a2fa62a8229c1cf6697ac154b4fd29 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:25:54 -0500
Subject: [PATCH 4/8] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 124 ++++++
 7 files changed, 732 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..837375b36472
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 7cd40017af3f630a4c05d29a389c86cf4d9119be Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:19 -0500
Subject: [PATCH 5/8] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 119 +++++++
 7 files changed, 682 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..c34b77ab6e68
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 83d2139e6151014fb31396c21a892a4de03892a7 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:32 -0500
Subject: [PATCH 6/8] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 119 ++++++++++++
 5 files changed, 485 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..b17133c4e97a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,119 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From d15c9c04abc6a00cffae7e880f93bd5716d1e5fa Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Mon, 17 Jan 2022 06:26:59 -0500
Subject: [PATCH 7/8] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 ++++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 +++++++++++
 srcpkgs/openjdk17/template                    | 210 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 586 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index 76df17e8ba13..42f8a4e1e4b5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4102,3 +4102,9 @@ libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
 libdeflate.so.0 libdeflate-1.8_1
+libjawt.so openjdk17-17.0.1+12_1
+libawt.so openjdk17-17.0.1+12_1
+libawt_xawt.so openjdk17-17.0.1+12_1
+libjava.so openjdk17-17.0.1+12_1
+libjli.so openjdk17-17.0.1+12_1
+libjvm.so openjdk17-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..bac3d502d783
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,210 @@
+# Template file for 'openjdk17'
+# TODO: split off -jre and -jre-headless subpackages
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-version-build=${_java_ver}
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
+ jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
+ jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+ jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+	vmkdir etc/profile.d
+	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

From 112ce0591ba1942e154064bf9f12d4ba1bf61213 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 1 Feb 2022 18:00:37 -0500
Subject: [PATCH 8/8] openjdk17: TEMP

---
 common/shlibs                        | 12 ++---
 srcpkgs/openjdk12-bootstrap/template | 11 ++++-
 srcpkgs/openjdk13-bootstrap/template | 32 +++++++++++++-
 srcpkgs/openjdk14-bootstrap/template | 11 ++++-
 srcpkgs/openjdk15-bootstrap/template | 11 ++++-
 srcpkgs/openjdk16-bootstrap/template | 11 ++++-
 srcpkgs/openjdk17-jre                |  1 +
 srcpkgs/openjdk17/template           | 66 +++++++++++++++++++---------
 8 files changed, 118 insertions(+), 37 deletions(-)
 create mode 120000 srcpkgs/openjdk17-jre

diff --git a/common/shlibs b/common/shlibs
index 42f8a4e1e4b5..c30d9fa8ceb9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4102,9 +4102,9 @@ libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
 libdeflate.so.0 libdeflate-1.8_1
-libjawt.so openjdk17-17.0.1+12_1
-libawt.so openjdk17-17.0.1+12_1
-libawt_xawt.so openjdk17-17.0.1+12_1
-libjava.so openjdk17-17.0.1+12_1
-libjli.so openjdk17-17.0.1+12_1
-libjvm.so openjdk17-17.0.1+12_1
+libjawt.so openjdk17-jre-17.0.1+12_1
+libawt.so openjdk17-jre-17.0.1+12_1
+libawt_xawt.so openjdk17-jre-17.0.1+12_1
+libjava.so openjdk17-jre-17.0.1+12_1
+libjli.so openjdk17-jre-17.0.1+12_1
+libjvm.so openjdk17-jre-17.0.1+12_1
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 813a67ac50a3..eeb928af8ac1 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 
@@ -109,7 +116,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 01c5c45883e8..0782342d5e27 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -61,6 +64,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -107,8 +114,29 @@ do_configure() {
 		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
 }
 
+do_build() {
+	# do_build is overridden because of intermittent segfaults and IOExceptions during the build
+	# through many attempts, it was found that 3 tries is a good amount to make it work
+	for _try in 1 2 3; do
+		msg_normal "Attempt $_try ...\n"
+
+		# adapted from build style
+		: ${make_cmd:=make}
+
+		export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
+		${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} && break
+		# end adapted from build style
+
+		if [ $_try -lt 3 ]; then
+			msg_warn "Build failed, retrying ...\n"
+		else
+			msg_warn "Build failed, out of attempts\n"
+		fi
+	done
+}
+
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
index 837375b36472..dc61ad9c466f 100644
--- a/srcpkgs/openjdk14-bootstrap/template
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-libpng=system
  --with-lcms=system
  --with-jtreg=no
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -60,6 +63,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -116,7 +123,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index c34b77ab6e68..a6d65a6b4300 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -21,8 +21,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -106,7 +113,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
index b17133c4e97a..085e9290cfeb 100644
--- a/srcpkgs/openjdk16-bootstrap/template
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -20,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -63,6 +66,10 @@ if [ -n "$_use_zero" ]; then
 	esac
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 post_extract() {
 	chmod +x configure
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
@@ -106,7 +113,7 @@ do_configure() {
 }
 
 post_install() {
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	rm -rf ${DESTDIR}/usr/lib/bin
 	rm -f $DESTDIR/$_jdk_home/lib/src.zip
 	vlicense ASSEMBLY_EXCEPTION
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
index bac3d502d783..5b8b801513cb 100644
--- a/srcpkgs/openjdk17/template
+++ b/srcpkgs/openjdk17/template
@@ -1,5 +1,4 @@
 # Template file for 'openjdk17'
-# TODO: split off -jre and -jre-headless subpackages
 _java_ver=17
 _java_min_ver=0
 _java_sec_ver=1
@@ -21,8 +20,11 @@ configure_args="--disable-warnings-as-errors
  --with-lcms=system
  --with-jtreg=no
  --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
- --with-version-build=${_java_ver}
+ --with-debug-level=release
  --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
  --with-vendor-name=Void
  --with-vendor-url=https://voidlinux.org/
  --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
@@ -35,7 +37,8 @@ hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
 makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
  giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
  fontconfig-devel zlib-devel lcms2-devel"
-provides="java-environment-${version}_1 java-runtime-${version}_1"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
 short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
 maintainer="classabbyamp <dev@kb6.ee>"
 license="GPL-2.0-only WITH Classpath-exception-2.0"
@@ -44,7 +47,6 @@ distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.ta
  https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
 checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
  9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
-shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
 
 # Build is still parallel, but don't use -jN.
 disable_parallel_build=yes
@@ -77,16 +79,16 @@ else
 	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
 fi
 
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
 alternatives="
  java:/usr/bin/java:/${_jdk_home}/bin/java
- java:/usr/bin/jjs:/${_jdk_home}/bin/jjs
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- java:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- java:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
- java:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 
- jdk:/usr/bin/jaotc:/${_jdk_home}/bin/jaotc
  jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
  jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
  jdk:/usr/bin/java:/${_jdk_home}/bin/java
@@ -98,13 +100,14 @@ alternatives="
  jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
  jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
  jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
  jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
  jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
  jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
- jdk:/usr/bin/jjs:/${_jdk_home}/bin/jjs
  jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
  jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
  jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
  jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
  jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
  jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
@@ -112,12 +115,8 @@ alternatives="
  jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
  jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
  jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
- jdk:/usr/bin/pack200:/${_jdk_home}/bin/pack200
- jdk:/usr/bin/rmic:/${_jdk_home}/bin/rmic
- jdk:/usr/bin/rmid:/${_jdk_home}/bin/rmid
  jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
  jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
- jdk:/usr/bin/unpack200:/${_jdk_home}/bin/unpack200
 "
 
 post_extract() {
@@ -164,18 +163,12 @@ do_configure() {
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/lib/bin
-	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version}-internal ${DESTDIR}/$_jdk_home
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
 	vmkdir $_jdk_home/lib/security
 	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
 	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
 	chmod -R ugo+rw ./ca
 	rm -rf ./ca
-	vmkdir etc/profile.d
-	cat >>${DESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
-	vlicense ASSEMBLY_EXCEPTION
-	vlicense LICENSE
 }
 
 do_clean() {
@@ -183,6 +176,37 @@ do_clean() {
 	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
 }
 
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
 openjdk17-doc_package() {
 	nostrip=yes
 	noverifyrdeps=yes

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (32 preceding siblings ...)
  2022-02-03 19:59 ` classabbyamp
@ 2022-02-03 20:03 ` classabbyamp
  2022-02-03 20:06 ` classabbyamp
                   ` (14 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-03 20:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 160022 bytes --]

From 541d761098770ac9d08b935032b0ebf2b11935c0 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/7] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4b2f29a37f32368ad56bc177cddf0ffe87170d5b Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:01:53 -0500
Subject: [PATCH 2/7] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 124 ++++++
 6 files changed, 720 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..eeb928af8ac1
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 3b99ef6358121f167efd92f477d475a840a82fa8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:10 -0500
Subject: [PATCH 3/7] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 144 +++++++
 6 files changed, 740 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0782342d5e27
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,144 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+do_build() {
+	# do_build is overridden because of intermittent segfaults and IOExceptions during the build
+	# through many attempts, it was found that 3 tries is a good amount to make it work
+	for _try in 1 2 3; do
+		msg_normal "Attempt $_try ...\n"
+
+		# adapted from build style
+		: ${make_cmd:=make}
+
+		export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
+		${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} && break
+		# end adapted from build style
+
+		if [ $_try -lt 3 ]; then
+			msg_warn "Build failed, retrying ...\n"
+		else
+			msg_warn "Build failed, out of attempts\n"
+		fi
+	done
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6ed18d59ca8ab978332137b7e8dd8b71f5aa2de3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:24 -0500
Subject: [PATCH 4/7] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 131 ++++++
 7 files changed, 739 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..dc61ad9c466f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,131 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From bd75f1a532dee690b9c4b1c0f1f432f19cb94ed1 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:39 -0500
Subject: [PATCH 5/7] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 126 +++++++
 7 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..a6d65a6b4300
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,126 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From daa99e3e04cb322447c446bb27604e47e03a98db Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:49 -0500
Subject: [PATCH 6/7] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 126 +++++++++++++
 5 files changed, 492 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..085e9290cfeb
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,126 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 76979f9eff47ec3acb54782c2b1f1aa8012543d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:03:24 -0500
Subject: [PATCH 7/7] New package: openjdk17-17.0.1+12

---
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-jre                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 +++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++++++
 srcpkgs/openjdk17/template                    | 234 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 605 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-jre
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..5b8b801513cb
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,234 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (33 preceding siblings ...)
  2022-02-03 20:03 ` classabbyamp
@ 2022-02-03 20:06 ` classabbyamp
  2022-02-06 17:49 ` endigma
                   ` (13 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-03 20:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 160022 bytes --]

From 541d761098770ac9d08b935032b0ebf2b11935c0 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/7] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 4b2f29a37f32368ad56bc177cddf0ffe87170d5b Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:01:53 -0500
Subject: [PATCH 2/7] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 124 ++++++
 6 files changed, 720 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..eeb928af8ac1
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 3b99ef6358121f167efd92f477d475a840a82fa8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:10 -0500
Subject: [PATCH 3/7] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 144 +++++++
 6 files changed, 740 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0782342d5e27
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,144 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+do_build() {
+	# do_build is overridden because of intermittent segfaults and IOExceptions during the build
+	# through many attempts, it was found that 3 tries is a good amount to make it work
+	for _try in 1 2 3; do
+		msg_normal "Attempt $_try ...\n"
+
+		# adapted from build style
+		: ${make_cmd:=make}
+
+		export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
+		${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} && break
+		# end adapted from build style
+
+		if [ $_try -lt 3 ]; then
+			msg_warn "Build failed, retrying ...\n"
+		else
+			msg_warn "Build failed, out of attempts\n"
+		fi
+	done
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From 6ed18d59ca8ab978332137b7e8dd8b71f5aa2de3 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:24 -0500
Subject: [PATCH 4/7] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 131 ++++++
 7 files changed, 739 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..dc61ad9c466f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,131 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From bd75f1a532dee690b9c4b1c0f1f432f19cb94ed1 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:39 -0500
Subject: [PATCH 5/7] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 126 +++++++
 7 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..a6d65a6b4300
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,126 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From daa99e3e04cb322447c446bb27604e47e03a98db Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:49 -0500
Subject: [PATCH 6/7] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 126 +++++++++++++
 5 files changed, 492 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..085e9290cfeb
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,126 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 76979f9eff47ec3acb54782c2b1f1aa8012543d8 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:03:24 -0500
Subject: [PATCH 7/7] New package: openjdk17-17.0.1+12

---
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-jre                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 +++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++++++
 srcpkgs/openjdk17/template                    | 234 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 9 files changed, 605 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-jre
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..5b8b801513cb
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,234 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (34 preceding siblings ...)
  2022-02-03 20:06 ` classabbyamp
@ 2022-02-06 17:49 ` endigma
  2022-02-06 18:43 ` classabbyamp
                   ` (12 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: endigma @ 2022-02-06 17:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

New comment by endigma on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1030880820

Comment:
What's blocking merge?

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (35 preceding siblings ...)
  2022-02-06 17:49 ` endigma
@ 2022-02-06 18:43 ` classabbyamp
  2022-02-06 19:04 ` classabbyamp
                   ` (11 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-06 18:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 184 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1030890277

Comment:
nothing, just waiting for maintainers

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (36 preceding siblings ...)
  2022-02-06 18:43 ` classabbyamp
@ 2022-02-06 19:04 ` classabbyamp
  2022-02-09 22:51 ` dadudeme
                   ` (10 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-06 19:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 211 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1030890277

Comment:
nothing, just waiting for void maintainers to look over it fully

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (37 preceding siblings ...)
  2022-02-06 19:04 ` classabbyamp
@ 2022-02-09 22:51 ` dadudeme
  2022-02-09 22:54 ` motorto
                   ` (9 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: dadudeme @ 2022-02-09 22:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 290 bytes --]

New comment by dadudeme on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1034279630

Comment:
I am quite new to git hub but want to build this package could someone let me know how to do this or refer me to an explanation?
Thanks in advance

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (38 preceding siblings ...)
  2022-02-09 22:51 ` dadudeme
@ 2022-02-09 22:54 ` motorto
  2022-02-09 23:07 ` classabbyamp
                   ` (8 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: motorto @ 2022-02-09 22:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

New comment by motorto on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1034282545

Comment:
1) Clone the repo and cd into it
2) wget this url and at the end add .diff 
3) git apply the downloaded diff file and ./xbps-src pkg <namePackage>
On 22/02/09 02:51PM, dadudeme wrote:
> I am quite new to git hub but want to build this package could someone let me know how to do this or refer me to an explanation?
> Thanks in advance
> 
> -- 
> Reply to this email directly or view it on GitHub:
> https://github.com/void-linux/void-packages/pull/34989#issuecomment-1034279630
> You are receiving this because you are subscribed to this thread.
> 
> Message ID: ***@***.***>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (39 preceding siblings ...)
  2022-02-09 22:54 ` motorto
@ 2022-02-09 23:07 ` classabbyamp
  2022-02-09 23:07 ` classabbyamp
                   ` (7 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-09 23:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1034292966

Comment:
no need to do that weird diff process.

do step 1 above, then `git fetch origin pull/34989/head:openjdk17`, then don't forget to bootstrap with `./xbps-src binary-bootstrap` before running `./xbps-src pkg openjdk17`.

Once that's done, use `xi` from the package xtools to install the package to your system (`xi openjdk17`)

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (40 preceding siblings ...)
  2022-02-09 23:07 ` classabbyamp
@ 2022-02-09 23:07 ` classabbyamp
  2022-02-10 17:47 ` JamiKettunen
                   ` (6 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-09 23:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1034292966

Comment:
no need to do that weird diff process.

do step 1 above, then `git fetch origin pull/34989/head:openjdk17`, then `git checkout openjdk17`, then don't forget to bootstrap with `./xbps-src binary-bootstrap` before running `./xbps-src pkg openjdk17`.

Once that's done, use `xi` from the package xtools to install the package to your system (`xi openjdk17`)

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (41 preceding siblings ...)
  2022-02-09 23:07 ` classabbyamp
@ 2022-02-10 17:47 ` JamiKettunen
  2022-02-10 17:50 ` JamiKettunen
                   ` (5 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: JamiKettunen @ 2022-02-10 17:47 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

New comment by JamiKettunen on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1035229056

Comment:
Failed to build under `x86_64-musl` & `x86_64` with the following for me:
```
./xbps-src pkg openjdk17
...
Extracting Java cacerts (JKS) to /builddir/jdk17u-jdk-17.0.1-12/ca/etc/pki/tls/java/cacerts...Done!
=> ERROR: openjdk17-17.0.1+12_1: post_install: 'chmod -R ugo+rw ./ca' exited with 1
=> ERROR:   in post_install() at srcpkgs/openjdk17/template:170
```

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (42 preceding siblings ...)
  2022-02-10 17:47 ` JamiKettunen
@ 2022-02-10 17:50 ` JamiKettunen
  2022-02-10 17:52 ` JamiKettunen
                   ` (4 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: JamiKettunen @ 2022-02-10 17:50 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

New comment by JamiKettunen on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1035229056

Comment:
Failed to build under `x86_64-musl` & `x86_64` with the following for me:
```
./xbps-src pkg openjdk17
...
Extracting Java cacerts (JKS) to /builddir/jdk17u-jdk-17.0.1-12/ca/etc/pki/tls/java/cacerts...Done!
=> ERROR: openjdk17-17.0.1+12_1: post_install: 'chmod -R ugo+rw ./ca' exited with 1
=> ERROR:   in post_install() at srcpkgs/openjdk17/template:170
```
Fwiw I rebased this branch on latest void-packages master before building.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (43 preceding siblings ...)
  2022-02-10 17:50 ` JamiKettunen
@ 2022-02-10 17:52 ` JamiKettunen
  2022-02-10 21:14 ` [PR PATCH] [Updated] " classabbyamp
                   ` (3 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: JamiKettunen @ 2022-02-10 17:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

New comment by JamiKettunen on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1035229056

Comment:
Failed to build for `x86_64-musl` & `x86_64` (`x86-64-musl` masterdir) with the following for me:
```
./xbps-src pkg openjdk17
...
Extracting Java cacerts (JKS) to /builddir/jdk17u-jdk-17.0.1-12/ca/etc/pki/tls/java/cacerts...Done!
=> ERROR: openjdk17-17.0.1+12_1: post_install: 'chmod -R ugo+rw ./ca' exited with 1
=> ERROR:   in post_install() at srcpkgs/openjdk17/template:170
```
Fwiw I rebased this branch on latest void-packages master before building.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Updated] New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (44 preceding siblings ...)
  2022-02-10 17:52 ` JamiKettunen
@ 2022-02-10 21:14 ` classabbyamp
  2022-02-10 21:14 ` classabbyamp
                   ` (2 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-10 21:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34989

New package: openjdk17-17.0.1+12
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/34989.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-openjdk17-34989.patch --]
[-- Type: text/x-diff, Size: 160602 bytes --]

From 7c539bb450beee8368fef81b3b17643b9ac4bb1d Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Tue, 11 Jan 2022 02:56:04 -0500
Subject: [PATCH 1/7] shutils: introduce XBPS_ORIG_MAKEJOBS variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages couldn't work well with XBPS_MAKEJOBS,
thus we disable parallel build for those packages.

On the other hand, some packages including but not limited to openjdk
use an internal mechanism to build themselves in parallel.

Let's invent another variable for those packages.

(message by sgn)

Co-authored-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 common/xbps-src/shutils/common.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 1739124050f7..47ff365e9ff2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -465,7 +465,9 @@ setup_pkg() {
     DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
     PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
 
-    if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
+    : ${XBPS_MAKEJOBS:=1}
+    export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
+    if [ -n "$disable_parallel_build" ]; then
         XBPS_MAKEJOBS=1
     fi
     makejobs="-j$XBPS_MAKEJOBS"

From 156885b4b38514e706638a7493c2c3050171627b Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:01:53 -0500
Subject: [PATCH 2/7] New package: openjdk12-bootstrap-12.0.2+10

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk12-bootstrap/template          | 124 ++++++
 6 files changed, 720 insertions(+)
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk12-bootstrap/template

diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
new file mode 100644
index 000000000000..eeb928af8ac1
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,124 @@
+# Template file for 'openjdk12-bootstrap'
+_java_ver=12
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=10
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk12-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk11"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk11"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 12)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=b2bcad35656b00928683416f3480ad00363b00993eb711c3e1886e4fe77eefeb
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From f79f93ec68c068b01299235d589d02692e8ea10e Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:10 -0500
Subject: [PATCH 3/7] New package: openjdk13-bootstrap-13.0.2+8

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  24 ++
 .../files/musl_patches/build.patch            | 387 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 ++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk13-bootstrap/template          | 144 +++++++
 6 files changed, 740 insertions(+)
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk13-bootstrap/template

diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..adc452660df5
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,24 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -71,9 +71,20 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..8e239bfe7863
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,387 @@
+diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -71,6 +71,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -194,6 +194,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -99,7 +99,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -519,6 +518,11 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -536,6 +540,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -2855,20 +2860,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1148,7 +1148,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
+--- a/src/hotspot/share/runtime/vm_version.cpp
++++ b/src/hotspot/share/runtime/vm_version.cpp
+@@ -270,7 +270,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -234,7 +234,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+diff --git a/src/java.base/unix/native/libjava/jdk_util_md.h b/src/java.base/unix/native/libjava/jdk_util_md.h
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -235,6 +235,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      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/src/java.base/unix/native/libnio/ch/NativeThread.c b/src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -791,26 +788,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/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -254,13 +269,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -273,7 +294,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
new file mode 100644
index 000000000000..0782342d5e27
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,144 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=8
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk13-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk12"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk12-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 13)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="https://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=d38fb17795782dffe84e98f21f1d6293b0a45ea8f1e9c81e99cd71acac03a4e0
+lib32disabled=yes
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+do_build() {
+	# do_build is overridden because of intermittent segfaults and IOExceptions during the build
+	# through many attempts, it was found that 3 tries is a good amount to make it work
+	for _try in 1 2 3; do
+		msg_normal "Attempt $_try ...\n"
+
+		# adapted from build style
+		: ${make_cmd:=make}
+
+		export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
+		${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} && break
+		# end adapted from build style
+
+		if [ $_try -lt 3 ]; then
+			msg_warn "Build failed, retrying ...\n"
+		else
+			msg_warn "Build failed, out of attempts\n"
+		fi
+	done
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From aaee37d7e104346bc41f8eb43f20cb90a05f58da Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:24 -0500
Subject: [PATCH 4/7] New package: openjdk14-bootstrap-14.0.2+12

---
 .../files/i686_patches/JDK-8238909.patch      |  30 ++
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 +
 .../files/musl_patches/build.patch            | 372 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 ++++++
 srcpkgs/openjdk14-bootstrap/template          | 131 ++++++
 7 files changed, 739 insertions(+)
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14-bootstrap/template

diff --git a/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
new file mode 100644
index 000000000000..f19b0911cfab
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/i686_patches/JDK-8238909.patch
@@ -0,0 +1,30 @@
+# from https://bugs.openjdk.java.net/browse/JDK-8238909
+
+--- a/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 15:43:59 2020 +0000
++++ b/src/hotspot/share/utilities/powerOfTwo.hpp	Thu Feb 13 17:05:30 2020 +0100
+@@ -28,6 +28,7 @@
+ #include "metaprogramming/enableIf.hpp"
+ #include "metaprogramming/isIntegral.hpp"
+ #include "metaprogramming/isSigned.hpp"
++#include "utilities/align.hpp"
+ #include "utilities/count_leading_zeros.hpp"
+ #include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
+@@ -68,7 +69,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(IsSigned<T>::value);
+   assert(value > 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
+@@ -84,7 +85,7 @@
+   STATIC_ASSERT(IsIntegral<T>::value);
+   STATIC_ASSERT(!IsSigned<T>::value);
+   assert(value != 0, "Invalid value");
+-  if (is_power_of_2(value)) {
++  if (is_power_of_2_t(value)) {
+     return value;
+   }
+   uint32_t lz = count_leading_zeros(value);
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,372 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/lib/CoreLibraries.gmk
++++ b/make/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -274,7 +274,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md_solinux.c
++++ b/src/java.base/unix/native/libjli/java_md_solinux.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
++++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+@@ -27,9 +27,6 @@
+ #include <X11/Xutil.h>
+ #include <X11/Xos.h>
+ #include <X11/Xatom.h>
+-#ifdef __linux__
+-#include <execinfo.h>
+-#endif
+ 
+ #include <jvm.h>
+ #include <jni.h>
+@@ -780,26 +777,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;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk14-bootstrap/template b/srcpkgs/openjdk14-bootstrap/template
new file mode 100644
index 000000000000..dc61ad9c466f
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,131 @@
+# Template file for 'openjdk14-bootstrap'
+_java_ver=14
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk14-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk13"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk13-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel openjdk13-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 14)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		i686*)
+			for f in "${FILESDIR}"/i686_patches/*.patch; do
+				msg_normal "Applying ${f#$FILESDIR/}\n"
+				patch -lNp1 -i "$f"
+			done
+			;;
+	esac
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	# compatibility with GCC 10.x
+	CFLAGS+=" -fcommon -fno-lifetime-dse"
+	CXXFLAGS+=" -fcommon -fno-lifetime-dse"
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}

From a3ca77ab69583b0266467a15f6857c74fb58e74c Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:39 -0500
Subject: [PATCH 5/7] New package: openjdk15-bootstrap-15.0.3+3

---
 .../files/musl_patches/aarch64.patch          |  10 +
 .../files/musl_patches/arm.patch              |  21 ++
 .../files/musl_patches/build.patch            | 333 ++++++++++++++++++
 .../files/musl_patches/check.patch            |  24 ++
 .../files/musl_patches/ppc.patch              |  45 +++
 .../files/musl_patches/x86.patch              | 130 +++++++
 srcpkgs/openjdk15-bootstrap/template          | 126 +++++++
 7 files changed, 689 insertions(+)
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk15-bootstrap/template

diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/aarch64.patch
@@ -0,0 +1,10 @@
+--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
++++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+@@ -74,7 +74,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ 
+ #define REG_FP 29
+ #define REG_LR 30
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..503df469b584
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,333 @@
+--- a/make/ReleaseFile.gmk
++++ b/make/ReleaseFile.gmk
+@@ -53,6 +53,7 @@ define create-info-file
+   $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
+   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
++  $(call info-file-item, "LIBC", "musl")
+ endef
+ 
+ # Param 1 - The file containing the MODULES list
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -102,7 +102,6 @@
+ # include <string.h>
+ # include <syscall.h>
+ # include <sys/sysinfo.h>
+-# include <gnu/libc-version.h>
+ # include <sys/ipc.h>
+ # include <sys/shm.h>
+ # include <link.h>
+@@ -597,6 +596,12 @@ void os::Linux::hotspot_sigmask(Thread* thread) {
+ // detecting pthread library
+ 
+ void os::Linux::libpthread_init() {
++#if !defined(__GLIBC__) && !defined(__UCLIBC__)
++  // Hard code Alpine Linux supported musl compatible settings
++  // sgn: NPTL is correct, don't know about glibc 2.9, alpine's thing?
++  os::Linux::set_glibc_version("glibc 2.9");
++  os::Linux::set_libpthread_version("NPTL");
++#else
+   // Save glibc and pthread version strings.
+ #if !defined(_CS_GNU_LIBC_VERSION) || \
+     !defined(_CS_GNU_LIBPTHREAD_VERSION)
+@@ -614,6 +619,7 @@ void os::Linux::libpthread_init() {
+   str = (char *)malloc(n, mtInternal);
+   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+   os::Linux::set_libpthread_version(str);
++#endif
+ }
+ 
+ /////////////////////////////////////////////////////////////////////////////
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
++++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
+@@ -262,7 +262,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() {
+   #endif
+ 
+   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
+-         " for " OS "-" CPU FLOAT_ARCH_STR \
++         " for " OS "-" CPU FLOAT_ARCH_STR LIBC \
+          " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
+          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
+ 
+--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
++++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
+@@ -204,7 +204,7 @@ inline int g_isnan(double f) { return isnand(f); }
+ #elif defined(__APPLE__)
+ inline int g_isnan(double f) { return isnan(f); }
+ #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
+-inline int g_isnan(float  f) { return isnanf(f); }
++inline int g_isnan(float  f) { return isnan(f); }
+ inline int g_isnan(double f) { return isnan(f); }
+ #else
+ #error "missing platform-specific definition here"
+--- a/src/java.base/linux/native/libnet/linux_close.c
++++ b/src/java.base/linux/native/libnet/linux_close.c
+@@ -60,7 +60,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
+@@ -149,6 +149,7 @@ static void __attribute((constructor)) init() {
+     /*
+      * Setup the signal handler
+      */
++    sigWakeup = SIGRTMAX - 2;
+     sa.sa_handler = sig_wakeup;
+     sa.sa_flags   = 0;
+     sigemptyset(&sa.sa_mask);
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjava/jdk_util_md.h
++++ b/src/java.base/unix/native/libjava/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>
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -230,6 +230,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c
+@@ -36,7 +36,7 @@
+ #ifdef __linux__
+   #include <pthread.h>
+   /* Also defined in net/linux_close.c */
+-  #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
++  #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+ #elif defined(_AIX)
+   #include <pthread.h>
+   /* Also defined in net/aix_close.c */
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
+--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
++++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+@@ -33,6 +33,7 @@
+ 
+ #include <assert.h>
+ #include <jni.h>
++#include <jvm.h>
+ #include <alloca.h>
+ #include <signal.h>
+ #include <string.h>
+@@ -91,6 +92,20 @@ void set_signal_handler() {
+   }
+ }
+ 
++int get_java_stacksize () {
++  size_t stacksize;
++  pthread_attr_t attr;
++  JDK1_1InitArgs jdk_args;
++
++  jdk_args.version = JNI_VERSION_1_1;
++  JNI_GetDefaultJavaVMInitArgs(&jdk_args);
++  if (jdk_args.javaStackSize <= 0) {
++    fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
++    exit(7);
++  }
++  return jdk_args.javaStackSize;
++}
++
+ void *run_java_overflow (void *p) {
+   JNIEnv *env;
+   jclass class_id;
+@@ -258,13 +273,19 @@ int main (int argc, const char** argv) {
+     exit(7);
+   }
+ 
++  int stack_size = get_java_stacksize();
+   pthread_t thr;
++  pthread_attr_t thread_attr;
++
++  pthread_attr_init(&thread_attr);
++  pthread_attr_setstacksize(&thread_attr, stack_size);
+ 
+   if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+     printf("\nTesting JAVA_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_java_overflow, NULL);
++
++    pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
+@@ -277,7 +298,7 @@ int main (int argc, const char** argv) {
+     printf("\nTesting NATIVE_OVERFLOW\n");
+ 
+     printf("Testing stack guard page behaviour for other thread\n");
+-    pthread_create (&thr, NULL, run_native_overflow, NULL);
++    pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
+     pthread_join (thr, NULL);
+ 
+     printf("Testing stack guard page behaviour for initial thread\n");
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
new file mode 100644
index 000000000000..250c7eede209
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/check.patch
@@ -0,0 +1,24 @@
+--- a/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
++++ b/test/hotspot/jtreg/runtime/TLS/exestack-tls.c
+@@ -26,7 +26,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <gnu/libc-version.h>
+ 
+ // Declare the thread local variable(s) in the main executable. This can be
+ // used to demonstrate the issues associated with the on-stack static TLS blocks
+@@ -56,13 +55,6 @@
+ 
+ // glibc 2.15 introduced __pthread_get_minstack
+ int glibc_has_pthread_get_minstack() {
+-  const char* glibc_vers = gnu_get_libc_version();
+-  const int glibc_vers_major = atoi(glibc_vers);
+-  const int glibc_vers_minor = atoi(strchr(glibc_vers, '.') + 1);;
+-  printf("GNU libc version: %s\n", glibc_vers);
+-  if ((glibc_vers_major > 2) || ((glibc_vers_major == 2) && (glibc_vers_minor >= 15))) {
+-    return 1;
+-  }
+   printf("This version does not provide __pthread_get_minstack\n");
+   return 0;
+ }
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
new file mode 100644
index 000000000000..a6d65a6b4300
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,126 @@
+# Template file for 'openjdk15-bootstrap'
+_java_ver=15
+_java_min_ver=0
+_java_sec_ver=3
+_jdk_update=3
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk15-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${version}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --prefix=${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk14"
+make_build_args="images"
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk14-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk14-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 15)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="4bbd7a73354a2d244c7a075406339aa0ce4c5fc6be91a795af931f6dc95d067c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From 20f5848fe21afcc29b36a77f1b554efb3923ef00 Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:02:49 -0500
Subject: [PATCH 6/7] New package: openjdk16-bootstrap-16.0.2+7

---
 .../files/musl_patches/arm.patch              |  21 +++
 .../files/musl_patches/build.patch            | 170 ++++++++++++++++++
 .../files/musl_patches/ppc.patch              |  45 +++++
 .../files/musl_patches/x86.patch              | 130 ++++++++++++++
 srcpkgs/openjdk16-bootstrap/template          | 126 +++++++++++++
 5 files changed, 492 insertions(+)
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk16-bootstrap/template

diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/arm.patch
@@ -0,0 +1,21 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,6 +73,18 @@
+ # include <ucontext.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk16-bootstrap/template b/srcpkgs/openjdk16-bootstrap/template
new file mode 100644
index 000000000000..085e9290cfeb
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,126 @@
+# Template file for 'openjdk16-bootstrap'
+_java_ver=16
+_java_min_ver=0
+_java_sec_ver=2
+_jdk_update=7
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk16-bootstrap
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-boot-jdk=/usr/lib/jvm/openjdk15"
+make_build_args="images"
+make_install_args="INSTALL_PREFIX=\"${XBPS_DESTDIR}/${pkgname}-${version}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca openjdk15-bootstrap"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel harfbuzz-devel openjdk15-bootstrap"
+provides="java-environment-${version}_1 java-runtime-${version}_1"
+short_desc="OpenJDK Java Development Kit (bootstrap version 16)"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="b4a0e71e41a11175e8a7c1dba86ed5b0aa878413158c8d48813db1b64ac9536c
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+nocross=yes
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
+	if [ "$XBPS_CCACHE" ]; then
+		configure_args+=" --enable-ccache"
+	fi
+	CC="/usr/bin/cc"
+	CXX="/usr/bin/c++"
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	rm -rf ${DESTDIR}/usr/lib/bin
+	rm -f $DESTDIR/$_jdk_home/lib/src.zip
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}

From e024c5c6b31a71bb709385f8005e3e1ad9303d5a Mon Sep 17 00:00:00 2001
From: classabbyamp <dev@kb6.ee>
Date: Thu, 3 Feb 2022 15:03:24 -0500
Subject: [PATCH 7/7] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-jre                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 .../openjdk17/files/musl_patches/arm.patch    |  22 ++
 .../openjdk17/files/musl_patches/build.patch  | 170 +++++++++++++
 .../openjdk17/files/musl_patches/ppc.patch    |  45 ++++
 .../openjdk17/files/musl_patches/x86.patch    | 130 ++++++++++
 srcpkgs/openjdk17/template                    | 234 ++++++++++++++++++
 srcpkgs/openjdk17/update                      |   1 +
 10 files changed, 611 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-jre
 create mode 120000 srcpkgs/openjdk17-src
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk17/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk17/template
 create mode 100644 srcpkgs/openjdk17/update

diff --git a/common/shlibs b/common/shlibs
index 39137dbe048f..c01c520695a1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4104,3 +4104,9 @@ libkaddressbookprivate.so.5 kaddressbook-21.08.3_1
 libcodec2.so.1.0 codec2-1.0.1_1
 libx86emu.so.3 libx86emu-3.4_1
 libdeflate.so.0 libdeflate-1.8_1
+libjawt.so openjdk17-jre-17.0.1+12_1
+libawt.so openjdk17-jre-17.0.1+12_1
+libawt_xawt.so openjdk17-jre-17.0.1+12_1
+libjava.so openjdk17-jre-17.0.1+12_1
+libjli.so openjdk17-jre-17.0.1+12_1
+libjvm.so openjdk17-jre-17.0.1+12_1
diff --git a/srcpkgs/openjdk17-doc b/srcpkgs/openjdk17-doc
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-doc
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-jre b/srcpkgs/openjdk17-jre
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-jre
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17-src b/srcpkgs/openjdk17-src
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-src
@@ -0,0 +1 @@
+openjdk17
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/arm.patch b/srcpkgs/openjdk17/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..32b4b0102a8e
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/arm.patch
@@ -0,0 +1,22 @@
+--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
++++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+@@ -73,7 +73,18 @@
+ # include <ucontext.h>
+-# include <fpu_control.h>
+ # include <asm/ptrace.h>
+ 
++// Stupid hack as the origin if below doesnt compile with gcc 8.2.0:
++//
++// os_linux_arm.cpp:114:5: error: missing binary operator before token "("
++//  #if NGREG == 16
++//       ^~~~~
++//
++// The NGREG is 18 (bits/signal.h:10), so force it to that value.
++#ifdef NGREG
++#  undef NGREG
++#endif
++#define NGREG 18
++
+ #define SPELL_REG_SP  "sp"
+ 
+ // Don't #define SPELL_REG_FP for thumb because it is not safe to use, so this makes sure we never fetch it.
diff --git a/srcpkgs/openjdk17/files/musl_patches/build.patch b/srcpkgs/openjdk17/files/musl_patches/build.patch
new file mode 100644
index 000000000000..1158babcd96d
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/build.patch
@@ -0,0 +1,170 @@
+--- a/make/hotspot/lib/CompileJvm.gmk
++++ b/make/hotspot/lib/CompileJvm.gmk
+@@ -73,6 +73,7 @@ CFLAGS_VM_VERSION := \
+     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
+     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
+     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
++    -DLIBC='"musl"' \
+     #
+ 
+ ################################################################################
+--- a/make/modules/java.base/lib/CoreLibraries.gmk
++++ b/make/modules/java.base/lib/CoreLibraries.gmk
+@@ -190,6 +190,7 @@ ifeq ($(call isTargetOs, windows), true)
+ endif
+ 
+ LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
++LIBJLI_CFLAGS += -DLIBC=\"musl\"
+ 
+ ifneq ($(USE_EXTERNAL_LIBZ), true)
+   LIBJLI_EXTRA_FILES += \
+--- a/src/hotspot/os/linux/os_linux.cpp
++++ b/src/hotspot/os/linux/os_linux.cpp
+@@ -3117,20 +3123,36 @@ void os::Linux::sched_getcpu_init() {
+ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+ extern "C" JNIEXPORT void numa_error(char *where) { }
+ 
++static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
++  typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
++  static dlvsym_func_type dlvsym_func;
++  static bool initialized = false;
++
++  if (!initialized) {
++    dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
++    initialized = true;
++  }
++
++  if (dlvsym_func != NULL) {
++    void *f = dlvsym_func(handle, name, version);
++    if (f != NULL) {
++      return f;
++    }
++  }
++
++  return dlsym(handle, name);
++}
++
+ // 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) {
+-  void *f = dlvsym(handle, name, "libnuma_1.1");
+-  if (f == NULL) {
+-    f = dlsym(handle, name);
+-  }
+-  return f;
++  return dlvsym_if_available(handle, name, "libnuma_1.1");
+ }
+ 
+ // Handle request to load libnuma symbol version 1.2 (API v2) only.
+ // Return NULL if the symbol is not defined in this particular version.
+ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
+-  return dlvsym(handle, name, "libnuma_1.2");
++  return dlvsym_if_available(handle, name, "libnuma_1.2");
+ }
+ 
+ bool os::Linux::libnuma_init() {
+--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -75,9 +75,6 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-#ifndef AMD64
+-# include <fpu_control.h>
+-#endif
+ 
+ #ifdef AMD64
+ #define REG_SP REG_RSP
+--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
++++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+@@ -1116,7 +1116,7 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
+ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
+   bool first = true;
+   size_t min_size = 0;   // "first" makes this conceptually infinite.
+-  ScratchBlock **smallest_ptr, *smallest;
++  ScratchBlock **smallest_ptr = NULL, *smallest;
+   ScratchBlock  *cur = *prev_ptr;
+   while (cur) {
+     assert(*prev_ptr == cur, "just checking");
+--- a/src/java.base/unix/native/libjava/childproc.c
++++ b/src/java.base/unix/native/libjava/childproc.c
+@@ -235,7 +235,13 @@ JDK_execvpe(int mode, const char *file,
+ {
+     if (envp == NULL || (char **) envp == environ) {
+         execvp(file, (char **) argv);
+-        return;
++        // ENOEXEC indicates that the file header was not recognized. The musl C
++        // library does not implement the fallback to /bin/sh for that case, so fall
++        // through to the code below which implements that fallback using
++        // execve_with_shell_fallback.
++        if (errno != ENOEXEC) {
++            return;
++        }
+     }
+ 
+     if (*file == '\0') {
+--- a/src/java.base/unix/native/libjli/java_md.c
++++ b/src/java.base/unix/native/libjli/java_md.c
+@@ -236,6 +236,39 @@ RequiresSetenv(const char *jvmpath) {
+     char *dmllp = NULL;
+     char *p; /* a utility pointer */
+ 
++#ifdef __linux
++#ifndef LIBC
++#error "LIBC not set"
++#endif
++
++    if (strcmp(LIBC, "musl") == 0) {
++      /*
++       * The musl library loader requires LD_LIBRARY_PATH to be set in
++       * order to correctly resolve the dependency libjava.so has on libjvm.so.
++       *
++       * Specifically, it differs from glibc in the sense that even if
++       * libjvm.so has already been loaded it will not be considered a
++       * candidate for resolving the dependency unless the *full* path
++       * of the already loaded library matches the dependency being loaded.
++       *
++       * libjvm.so is being loaded by the launcher using a long path to
++       * dlopen, not just the basename of the library. Typically this
++       * is something like "../lib/server/libjvm.so". However, if/when
++       * libjvm.so later tries to dlopen libjava.so (which it does in
++       * order to get access to a few functions implemented in
++       * libjava.so) the musl loader will, as part of loading
++       * dependent libraries, try to load libjvm.so using only its
++       * basename "libjvm.so". Since this does not match the longer
++       * path path it was first loaded with, the already loaded
++       * library is not considered a candidate, and the loader will
++       * instead look for libjvm.so elsewhere. If it's not in
++       * LD_LIBRARY_PATH the dependency load will fail, and libjava.so
++       * will therefore fail as well.
++       */
++      return JNI_TRUE;
++    }
++#endif
++
+ #ifdef AIX
+     /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+     return JNI_TRUE;
+--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
++++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
+@@ -35,15 +35,15 @@
+ #ifdef DEBUG
+     /* Just to make sure these interfaces are not used here. */
+     #undef free
+-    #define free(p) Do not use this interface.
++    #define free do_not_use_this_interface_free
+     #undef malloc
+-    #define malloc(p) Do not use this interface.
++    #define malloc do_not_use_this_interface_malloc
+     #undef calloc
+-    #define calloc(p) Do not use this interface.
++    #define calloc do_not_use_this_interface_calloc
+     #undef realloc
+-    #define realloc(p) Do not use this interface.
++    #define realloc do_not_use_this_interface_realloc
+     #undef strdup
+-    #define strdup(p) Do not use this interface.
++    #define strdup do_not_use_this_interface_strdup
+ #endif
+ 
+ #include "log_messages.h"
\ No newline at end of file
diff --git a/srcpkgs/openjdk17/files/musl_patches/ppc.patch b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/ppc.patch
@@ -0,0 +1,45 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+@@ -47,6 +47,8 @@
+ #include "opto/intrinsicnode.hpp"
+ #endif
+ 
++#include <asm/ptrace.h>
++
+ #ifdef PRODUCT
+ #define BLOCK_COMMENT(str) // nothing
+ #else
+--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+@@ -845,7 +845,7 @@ void VM_Version::determine_features() {
+   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
+@@ -75,7 +75,7 @@
+ # include <pwd.h>
+ # include <poll.h>
+ # include <ucontext.h>
+-
++# include <asm/ptrace.h>
+ 
+ address os::current_stack_pointer() {
+   intptr_t* csp;
+--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+@@ -23,6 +23,8 @@
+  *
+  */
+ 
++#include <asm/ptrace.h>
++
+ #include "precompiled.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
diff --git a/srcpkgs/openjdk17/files/musl_patches/x86.patch b/srcpkgs/openjdk17/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk17/files/musl_patches/x86.patch
@@ -0,0 +1,130 @@
+Patches for musl taken from Alpine linux: https://git.alpinelinux.org/aports/commit/?id=8a1ae17d4a9af54285c7891a680620e7e24c6280
+--- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
++++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+@@ -90,6 +90,126 @@
+ #define SPELL_REG_FP "ebp"
+ #endif // AMD64
+
++// ==============================================================================
++// Taken from glibc 2.28
++// source: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu_control.h;h=4cb98c5679b2897ff4e5826d228cba6be589e24d;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b
++// ==============================================================================
++#ifndef AMD64
++/* FPU control word bits.  x86 version.
++   Copyright (C) 1993-2018 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++   Contributed by Olaf Flebbe.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library 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
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef _FPU_CONTROL_H
++#define _FPU_CONTROL_H	1
++
++/* Note that this file sets on x86-64 only the x87 FPU, it does not
++   touch the SSE unit.  */
++
++/* Here is the dirty part. Set up your 387 through the control word
++ * (cw) register.
++ *
++ *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
++ * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
++ *
++ * IM: Invalid operation mask
++ * DM: Denormalized operand mask
++ * ZM: Zero-divide mask
++ * OM: Overflow mask
++ * UM: Underflow mask
++ * PM: Precision (inexact result) mask
++ *
++ * Mask bit is 1 means no interrupt.
++ *
++ * PC: Precision control
++ * 11 - round to extended precision
++ * 10 - round to double precision
++ * 00 - round to single precision
++ *
++ * RC: Rounding control
++ * 00 - rounding to nearest
++ * 01 - rounding down (toward - infinity)
++ * 10 - rounding up (toward + infinity)
++ * 11 - rounding toward zero
++ *
++ * IC: Infinity control
++ * That is for 8087 and 80287 only.
++ *
++ * The hardware default is 0x037f which we use.
++ */
++
++#include <features.h>
++
++/* masking of interrupts */
++#define _FPU_MASK_IM  0x01
++#define _FPU_MASK_DM  0x02
++#define _FPU_MASK_ZM  0x04
++#define _FPU_MASK_OM  0x08
++#define _FPU_MASK_UM  0x10
++#define _FPU_MASK_PM  0x20
++
++/* precision control */
++#define _FPU_EXTENDED 0x300	/* libm requires double extended precision.  */
++#define _FPU_DOUBLE   0x200
++#define _FPU_SINGLE   0x0
++
++/* rounding control */
++#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
++#define _FPU_RC_DOWN    0x400
++#define _FPU_RC_UP      0x800
++#define _FPU_RC_ZERO    0xC00
++
++#define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
++
++
++/* The fdlibm code requires strict IEEE double precision arithmetic,
++   and no interrupts for exceptions, rounding to nearest.  */
++
++#define _FPU_DEFAULT  0x037f
++
++/* IEEE:  same as above.  */
++#define _FPU_IEEE     0x037f
++
++/* Type of the control word.  */
++typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
++
++/* Macros for accessing the hardware control word.  "*&" is used to
++   work around a bug in older versions of GCC.  __volatile__ is used
++   to support combination of writing the control register and reading
++   it back.  Without __volatile__, the old value may be used for reading
++   back under compiler optimization.
++
++   Note that the use of these macros is not sufficient anymore with
++   recent hardware nor on x86-64.  Some floating point operations are
++   executed in the SSE/SSE2 engines which have their own control and
++   status register.  */
++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
++
++/* Default control word set at startup.  */
++extern fpu_control_t __fpu_control;
++
++#endif	/* fpu_control.h */
++
++#endif // AMD64
++// ==============================================================================
++// ==============================================================================
++// ==============================================================================
++
+ address os::current_stack_pointer() {
+ #ifdef SPARC_WORKS
+   register void *esp;
diff --git a/srcpkgs/openjdk17/template b/srcpkgs/openjdk17/template
new file mode 100644
index 000000000000..5b8b801513cb
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,234 @@
+# Template file for 'openjdk17'
+_java_ver=17
+_java_min_ver=0
+_java_sec_ver=1
+_jdk_update=12
+_jdk_home="usr/lib/jvm/openjdk${_java_ver}"
+_base_version="${_java_ver}.${_java_min_ver}.${_java_sec_ver}"
+
+pkgname=openjdk17
+version="${_base_version}+${_jdk_update}"
+revision=1
+wrksrc="jdk${_java_ver}u-jdk-${_base_version}-${_jdk_update}"
+build_style=gnu-configure
+configure_args="--disable-warnings-as-errors
+ --enable-unlimited-crypto
+ --with-zlib=system
+ --with-libjpeg=system
+ --with-giflib=system
+ --with-libpng=system
+ --with-lcms=system
+ --with-jtreg=no
+ --with-gtest=${XBPS_BUILDDIR}/googletest-release-1.8.1
+ --with-debug-level=release
+ --with-jobs=${XBPS_ORIG_MAKEJOBS}
+ --with-version-pre=
+ --with-version-build=${_jdk_update}
+ --with-version-opt=void-r${revision}
+ --with-vendor-name=Void
+ --with-vendor-url=https://voidlinux.org/
+ --with-vendor-bug-url=https://github.com/void-linux/void-packages/issues
+ --with-vendor-vm-bug-url=https://github.com/void-linux/void-packages/issues"
+make_build_args="images $(vopt_if docs docs)"
+make_install_args="INSTALL_PREFIX=\"${DESTDIR}/usr/lib\""
+make_check_target="test-hotspot-gtest"
+hostmakedepends="pkg-config automake autoconf cpio tar unzip zip ca-certificates
+ libressl zlib-devel which make-ca"
+makedepends="libXrender-devel libXtst-devel libXt-devel libXrandr-devel
+ giflib-devel libjpeg-turbo-devel cups-devel freetype-devel alsa-lib-devel
+ fontconfig-devel zlib-devel lcms2-devel"
+depends="${pkgname}-jre-${version}_${revision}"
+provides="java-environment-${version}_1"
+short_desc="OpenJDK Java Development Kit (version ${_java_ver})"
+maintainer="classabbyamp <dev@kb6.ee>"
+license="GPL-2.0-only WITH Classpath-exception-2.0"
+homepage="http://openjdk.java.net/"
+distfiles="https://github.com/openjdk/jdk${_java_ver}u/archive/jdk-${version}.tar.gz
+ https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz"
+checksum="8c076203a6f85ab916b3e54de1992bcbcc5ffe580c52b1ac8d52ca7afb9f02d1
+ 9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
+
+# Build is still parallel, but don't use -jN.
+disable_parallel_build=yes
+build_options="docs"
+
+# no hotspot JIT for ppc32
+case "$XBPS_TARGET_MACHINE" in
+	ppc64*) ;;
+	ppc*) _use_zero=yes ;;
+esac
+
+if [ -n "$_use_zero" ]; then
+	makedepends+=" libffi-devel"
+	configure_args+=" --with-jvm-variants=zero"
+	case "$XBPS_TARGET_MACHINE" in
+	ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+	esac
+fi
+configure_args+=" --with-boot-jdk-jvmargs=-Xlog:disable"
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk16-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk16"
+else
+	hostmakedepends+=" openjdk17"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk17"
+fi
+
+if [ -n "$XBPS_DEBUG_PKGS" ]; then
+	configure_args+=" --with-native-debug-symbols=internal"
+fi
+
+alternatives="
+ java:/usr/bin/java:/${_jdk_home}/bin/java
+ java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+ java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+
+ jdk:/usr/bin/jar:/${_jdk_home}/bin/jar
+ jdk:/usr/bin/jarsigner:/${_jdk_home}/bin/jarsigner
+ jdk:/usr/bin/java:/${_jdk_home}/bin/java
+ jdk:/usr/bin/javac:/${_jdk_home}/bin/javac
+ jdk:/usr/bin/javadoc:/${_jdk_home}/bin/javadoc
+ jdk:/usr/bin/javap:/${_jdk_home}/bin/javap
+ jdk:/usr/bin/jcmd:/${_jdk_home}/bin/jcmd
+ jdk:/usr/bin/jconsole:/${_jdk_home}/bin/jconsole
+ jdk:/usr/bin/jdb:/${_jdk_home}/bin/jdb
+ jdk:/usr/bin/jdeprscan:/${_jdk_home}/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/${_jdk_home}/bin/jdeps
+ jdk:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+ jdk:/usr/bin/jhsdb:/${_jdk_home}/bin/jhsdb
+ jdk:/usr/bin/jimage:/${_jdk_home}/bin/jimage
+ jdk:/usr/bin/jinfo:/${_jdk_home}/bin/jinfo
+ jdk:/usr/bin/jlink:/${_jdk_home}/bin/jlink
+ jdk:/usr/bin/jmap:/${_jdk_home}/bin/jmap
+ jdk:/usr/bin/jmod:/${_jdk_home}/bin/jmod
+ jdk:/usr/bin/jpackage:/${_jdk_home}/bin/jpackage
+ jdk:/usr/bin/jps:/${_jdk_home}/bin/jps
+ jdk:/usr/bin/jrunscript:/${_jdk_home}/bin/jrunscript
+ jdk:/usr/bin/jshell:/${_jdk_home}/bin/jshell
+ jdk:/usr/bin/jstack:/${_jdk_home}/bin/jstack
+ jdk:/usr/bin/jstat:/${_jdk_home}/bin/jstat
+ jdk:/usr/bin/jstatd:/${_jdk_home}/bin/jstatd
+ jdk:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+ jdk:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+ jdk:/usr/bin/serialver:/${_jdk_home}/bin/serialver
+"
+
+post_extract() {
+	chmod +x configure
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		rm -r src/jdk.hotspot.agent
+	fi
+}
+
+post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		for f in "${FILESDIR}"/musl_patches/*.patch; do
+			msg_normal "Applying ${f#$FILESDIR/}\n"
+			patch -lNp1 -i "$f"
+		done
+	fi
+}
+
+do_configure() {
+	CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
+	CXXFLAGS=${CXXFLAGS/-D_FORTIFY_SOURCE=2/}
+
+	# force ELFv2 for ppc64 just in case
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64*)
+			CFLAGS+=" -DABI_ELFv2"
+			CXXFLAGS+=" -DABI_ELFv2"
+			;;
+	esac
+
+	configure_args=${configure_args/--with-libtool-sysroot=$XBPS_CROSS_BASE}
+	if [ "$XBPS_CCACHE" ] && [ -z "$CROSS_BUILD" ]; then
+		configure_args+=" --enable-ccache"
+		CC="/usr/bin/cc"
+		CXX="/usr/bin/c++"
+	fi
+	./configure ${configure_args} \
+		--with-extra-cflags="$CFLAGS" \
+		--with-extra-cxxflags="$CXXFLAGS" \
+		--with-extra-ldflags="$LDFLAGS" \
+		READELF=$READELF AR=$AR STRIP=$STRIP NM=$NM \
+		OBJDUMP=$OBJDUMP OBJCOPY=$OBJCOPY
+}
+
+post_install() {
+	rm -rf ${DESTDIR}/usr/lib/bin
+	mv ${DESTDIR}/usr/lib/jvm/openjdk-${_base_version} ${DESTDIR}/$_jdk_home
+	vmkdir $_jdk_home/lib/security
+	make-ca -g -f --destdir "${PWD}/ca" -k "${DESTDIR}/$_jdk_home/bin/keytool"
+	mv ./ca/etc/pki/tls/java/cacerts ${DESTDIR}/$_jdk_home/lib/security/
+	chmod -R ugo+rw ./ca
+	rm -rf ./ca
+}
+
+do_clean() {
+	# clean up gtest
+	rm -rf ${XBPS_BUILDDIR}/googletest-release-*
+}
+
+subpackages="openjdk17-src openjdk17-jre openjdk17-doc"
+
+openjdk17-jre_package() {
+	shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.so"
+	short_desc+=" - runtime components"
+	provides="java-runtime-${version}_1"
+	alternatives="
+	 java:/usr/bin/java:/${_jdk_home}/bin/java
+	 java:/usr/bin/jfr:/${_jdk_home}/bin/jfr
+	 java:/usr/bin/keytool:/${_jdk_home}/bin/keytool
+	 java:/usr/bin/rmiregistry:/${_jdk_home}/bin/rmiregistry
+	"
+	pkg_install() {
+		for bf in java jfr keytool rmiregistry; do
+			vmove $_jdk_home/bin/$bf
+		done
+
+		for f in lib legal conf release; do
+			vmove $_jdk_home/$f
+		done
+
+		vmkdir etc/profile.d
+		cat >>${PKGDESTDIR}/etc/profile.d/10_openjdk17.sh <<-EOF
+export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+EOF
+
+		vlicense ASSEMBLY_EXCEPTION
+		vlicense LICENSE
+	}
+}
+
+openjdk17-doc_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - documentation"
+	pkg_install() {
+		cd ${wrksrc}
+		if [ "$build_option_docs" ]; then
+			local _docdir=usr/share/doc/openjdk$_java_ver
+			vmkdir $_docdir
+			cp -a build/linux-*/images/docs/* ${PKGDESTDIR}/$_docdir
+		fi
+		vmove $_jdk_home/man/man1
+	}
+}
+
+openjdk17-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" - source code"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}
diff --git a/srcpkgs/openjdk17/update b/srcpkgs/openjdk17/update
new file mode 100644
index 000000000000..baa13a22f358
--- /dev/null
+++ b/srcpkgs/openjdk17/update
@@ -0,0 +1 @@
+pattern='jdk-\K17\.[\d.+]+'
\ No newline at end of file

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (45 preceding siblings ...)
  2022-02-10 21:14 ` [PR PATCH] [Updated] " classabbyamp
@ 2022-02-10 21:14 ` classabbyamp
  2022-02-10 21:15 ` classabbyamp
  2022-02-11 19:03 ` [PR PATCH] [Merged]: " leahneukirchen
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-10 21:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1035525141

Comment:
@JamiKettunen I just rebased to master and build on `x86_64-musl` and had no issues building

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (46 preceding siblings ...)
  2022-02-10 21:14 ` classabbyamp
@ 2022-02-10 21:15 ` classabbyamp
  2022-02-11 19:03 ` [PR PATCH] [Merged]: " leahneukirchen
  48 siblings, 0 replies; 50+ messages in thread
From: classabbyamp @ 2022-02-10 21:15 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 230 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/34989#issuecomment-1035525141

Comment:
@JamiKettunen I just rebased to master and built on `x86_64-musl` and had no issues

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PR PATCH] [Merged]: New package: openjdk17-17.0.1+12
  2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
                   ` (47 preceding siblings ...)
  2022-02-10 21:15 ` classabbyamp
@ 2022-02-11 19:03 ` leahneukirchen
  48 siblings, 0 replies; 50+ messages in thread
From: leahneukirchen @ 2022-02-11 19:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1652 bytes --]

There's a merged pull request on the void-packages repository

New package: openjdk17-17.0.1+12
https://github.com/void-linux/void-packages/pull/34989

Description:
<!-- Uncomment relevant sections and delete options which are not applicable -->

Built upon the work of @sgn and @raedwulf.

Closes #32942
Supercedes #34390, #35078

#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->

#### Local build testing
- I built this PR locally for these architectures:

| arch | cross | built | `check` passes |
|:-----:|:-----:|:-----:|:-----:|
| x86_64 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| x86_64-musl || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| i686 || 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ | 12 ✔ <br> 13 ✔ <br> 14 ✔ <br> 15 ✔ <br> 16 ✔ <br> 17 ✔ |
| aarch64 | ✔ | 17 ✔ ||
| aarch64-musl | ✔ | 17 ✔ ||
| armv7l | ✔ | 17 ✔ ||
| armv6l-musl | ✔ | 17 ✔ ||

[ci skip]

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2022-02-11 19:03 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  8:29 [PR PATCH] [WIP] New package: openjdk17-17.0.1+12 classabbyamp
2022-01-12 21:56 ` [PR PATCH] [Updated] " classabbyamp
2022-01-12 21:58 ` classabbyamp
2022-01-13  4:23 ` classabbyamp
2022-01-14 21:59 ` classabbyamp
2022-01-15 17:09 ` classabbyamp
2022-01-15 17:10 ` classabbyamp
2022-01-15 17:11 ` classabbyamp
2022-01-15 17:58 ` Duncaen
2022-01-15 17:59 ` Duncaen
2022-01-15 18:46 ` classabbyamp
2022-01-16  2:53 ` [PR PATCH] [Updated] " classabbyamp
2022-01-16  2:57 ` classabbyamp
2022-01-17 10:49 ` classabbyamp
2022-01-17 11:16 ` classabbyamp
2022-01-17 11:23 ` classabbyamp
2022-01-17 11:27 ` classabbyamp
2022-01-17 15:49 ` EliteTK
2022-01-17 17:19 ` classabbyamp
2022-01-17 17:28 ` classabbyamp
2022-01-17 17:34 ` classabbyamp
2022-01-17 18:36 ` EliteTK
2022-01-17 20:15 ` classabbyamp
2022-01-17 20:51 ` classabbyamp
2022-01-17 22:48 ` motorto
2022-01-17 22:51 ` classabbyamp
2022-01-18  9:33 ` EliteTK
2022-01-18  9:35 ` EliteTK
2022-01-18  9:36 ` EliteTK
2022-02-01 23:01 ` [PR PATCH] [Updated] " classabbyamp
2022-02-01 23:11 ` classabbyamp
2022-02-03 19:13 ` classabbyamp
2022-02-03 19:15 ` classabbyamp
2022-02-03 19:59 ` classabbyamp
2022-02-03 20:03 ` classabbyamp
2022-02-03 20:06 ` classabbyamp
2022-02-06 17:49 ` endigma
2022-02-06 18:43 ` classabbyamp
2022-02-06 19:04 ` classabbyamp
2022-02-09 22:51 ` dadudeme
2022-02-09 22:54 ` motorto
2022-02-09 23:07 ` classabbyamp
2022-02-09 23:07 ` classabbyamp
2022-02-10 17:47 ` JamiKettunen
2022-02-10 17:50 ` JamiKettunen
2022-02-10 17:52 ` JamiKettunen
2022-02-10 21:14 ` [PR PATCH] [Updated] " classabbyamp
2022-02-10 21:14 ` classabbyamp
2022-02-10 21:15 ` classabbyamp
2022-02-11 19:03 ` [PR PATCH] [Merged]: " leahneukirchen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).