Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [WIP] Openjdk17
@ 2021-12-05 12:05 raedwulf
  2022-02-11 22:43 ` leahneukirchen
  2022-02-11 22:43 ` [PR PATCH] [Closed]: " leahneukirchen
  0 siblings, 2 replies; 3+ messages in thread
From: raedwulf @ 2021-12-05 12:05 UTC (permalink / raw)
  To: ml

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

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

https://github.com/raedwulf/void-packages openjdk17
https://github.com/void-linux/void-packages/pull/34390

[WIP] Openjdk17
This is open for feedback/other contributions because I don't really have the time to maintain this.
I've tested it only on x86-64 so there's a high chance that the musl patches are broken.

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

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

#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)

[ci skip]

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

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

From c4fabff379a6e4117e483d3523bb55286a8c021e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sat, 1 Aug 2020 22:36:40 +0700
Subject: [PATCH 1/8] shutils: introduce XBPS_ORIG_MAKEJOBS variable

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.
---
 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 e8bcf577c6b7..a5605c22d8cc 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -452,7 +452,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 eec587bb386eb8d621306a6cb86ca811fd2fc024 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sat, 1 Aug 2020 21:36:10 +0700
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          | 113 +++++
 6 files changed, 709 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..104807f1506a
--- /dev/null
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -0,0 +1,113 @@
+# 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="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-2.0-or-later"
+homepage="http://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 -slNp1 -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 bb87f541020f44a73f4218791380df4726fc5bf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sat, 1 Aug 2020 15:30:31 +0700
Subject: [PATCH 3/8] New package: openjdk13-bootstrap-13.0.4+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          | 113 +++++
 6 files changed, 709 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..4620da1dd4d0
--- /dev/null
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -0,0 +1,113 @@
+# Template file for 'openjdk13-bootstrap'
+_java_ver=13
+_java_min_ver=0
+_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}"
+
+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="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-2.0-or-later"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=5683638d5571ae1d8d3139ce7fdc3db26811f592d4f5a029f1e66cecd8666245
+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 -slNp1 -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 c36a1c2682c4312d083d3ffe734158b99411d45d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sat, 1 Aug 2020 07:52:18 +0700
Subject: [PATCH 4/8] New package: openjdk14-14.0.2+12

---
 srcpkgs/openjdk14-doc                         |   1 +
 srcpkgs/openjdk14-src                         |   1 +
 .../files/musl_patches/aarch64.patch          |  10 +
 .../openjdk14/files/musl_patches/arm.patch    |  21 +
 .../openjdk14/files/musl_patches/build.patch  | 372 ++++++++++++++++++
 .../openjdk14/files/musl_patches/ppc.patch    |  45 +++
 .../openjdk14/files/musl_patches/x86.patch    | 130 ++++++
 srcpkgs/openjdk14/template                    | 203 ++++++++++
 8 files changed, 783 insertions(+)
 create mode 120000 srcpkgs/openjdk14-doc
 create mode 120000 srcpkgs/openjdk14-src
 create mode 100644 srcpkgs/openjdk14/files/musl_patches/aarch64.patch
 create mode 100644 srcpkgs/openjdk14/files/musl_patches/arm.patch
 create mode 100644 srcpkgs/openjdk14/files/musl_patches/build.patch
 create mode 100644 srcpkgs/openjdk14/files/musl_patches/ppc.patch
 create mode 100644 srcpkgs/openjdk14/files/musl_patches/x86.patch
 create mode 100644 srcpkgs/openjdk14/template

diff --git a/srcpkgs/openjdk14-doc b/srcpkgs/openjdk14-doc
new file mode 120000
index 000000000000..1c6fdde19646
--- /dev/null
+++ b/srcpkgs/openjdk14-doc
@@ -0,0 +1 @@
+openjdk14
\ No newline at end of file
diff --git a/srcpkgs/openjdk14-src b/srcpkgs/openjdk14-src
new file mode 120000
index 000000000000..1c6fdde19646
--- /dev/null
+++ b/srcpkgs/openjdk14-src
@@ -0,0 +1 @@
+openjdk14
\ No newline at end of file
diff --git a/srcpkgs/openjdk14/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14/files/musl_patches/aarch64.patch
new file mode 100644
index 000000000000..aa6c5d4d2be2
--- /dev/null
+++ b/srcpkgs/openjdk14/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/files/musl_patches/arm.patch b/srcpkgs/openjdk14/files/musl_patches/arm.patch
new file mode 100644
index 000000000000..102428f10f33
--- /dev/null
+++ b/srcpkgs/openjdk14/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/files/musl_patches/build.patch b/srcpkgs/openjdk14/files/musl_patches/build.patch
new file mode 100644
index 000000000000..60dfdec30abc
--- /dev/null
+++ b/srcpkgs/openjdk14/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/files/musl_patches/ppc.patch b/srcpkgs/openjdk14/files/musl_patches/ppc.patch
new file mode 100644
index 000000000000..d306d501e4b8
--- /dev/null
+++ b/srcpkgs/openjdk14/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/files/musl_patches/x86.patch b/srcpkgs/openjdk14/files/musl_patches/x86.patch
new file mode 100644
index 000000000000..9c64c189036a
--- /dev/null
+++ b/srcpkgs/openjdk14/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/template b/srcpkgs/openjdk14/template
new file mode 100644
index 000000000000..d14547d551d8
--- /dev/null
+++ b/srcpkgs/openjdk14/template
@@ -0,0 +1,203 @@
+# Template file for 'openjdk14'
+_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
+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}/${XBPS_CROSS_TRIPLET}/${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"
+make_build_args="images $(vopt_if docs docs)"
+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="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-2.0-or-later"
+homepage="http://openjdk.java.net/"
+distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
+checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
+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"
+
+nocross="until host openjdk14 is available in build server"
+
+# 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
+
+case "$XBPS_TARGET_LIBC" in
+	glibc) build_options_default+=" docs";;
+esac
+
+if [ ! "$CROSS_BUILD" ]; then
+	hostmakedepends+=" openjdk13-bootstrap"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk13"
+else
+	hostmakedepends+=" openjdk14"
+	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk14"
+fi
+
+alternatives="
+ java:/usr/bin/java:/usr/lib/jvm/openjdk14/bin/java
+ java:/usr/bin/jjs:/usr/lib/jvm/openjdk14/bin/jjs
+ java:/usr/bin/keytool:/usr/lib/jvm/openjdk14/bin/keytool
+ java:/usr/bin/pack200:/usr/lib/jvm/openjdk14/bin/pack200
+ java:/usr/bin/rmid:/usr/lib/jvm/openjdk14/bin/rmid
+ java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk14/bin/rmiregistry
+ java:/usr/bin/unpack200:/usr/lib/jvm/openjdk14/bin/unpack200
+
+ jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk14/bin/jaotc
+ jdk:/usr/bin/jar:/usr/lib/jvm/openjdk14/bin/jar
+ jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk14/bin/jarsigner
+ jdk:/usr/bin/java:/usr/lib/jvm/openjdk14/bin/java
+ jdk:/usr/bin/javac:/usr/lib/jvm/openjdk14/bin/javac
+ jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk14/bin/javadoc
+ jdk:/usr/bin/javap:/usr/lib/jvm/openjdk14/bin/javap
+ jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk14/bin/jcmd
+ jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk14/bin/jconsole
+ jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk14/bin/jdb
+ jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk14/bin/jdeprscan
+ jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk14/bin/jdeps
+ jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk14/bin/jhsdb
+ jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk14/bin/jimage
+ jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk14/bin/jinfo
+ jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk14/bin/jjs
+ jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk14/bin/jlink
+ jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk14/bin/jmap
+ jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk14/bin/jmod
+ jdk:/usr/bin/jps:/usr/lib/jvm/openjdk14/bin/jps
+ jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk14/bin/jrunscript
+ jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk14/bin/jshell
+ jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk14/bin/jstack
+ jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk14/bin/jstat
+ jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk14/bin/jstatd
+ jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk14/bin/keytool
+ jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk14/bin/pack200
+ jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk14/bin/rmic
+ jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk14/bin/rmid
+ jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk14/bin/rmiregistry
+ jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk14/bin/serialver
+ jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk14/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 -slNp1 -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" ] && [ -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_openjdk14.sh <<-EOF
+	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
+	EOF
+	vlicense ASSEMBLY_EXCEPTION
+	vlicense LICENSE
+}
+
+openjdk14-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
+	}
+}
+
+openjdk14-src_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc+=" -- sources"
+	pkg_install() {
+		vmove "$_jdk_home/lib/src.zip"
+	}
+}

From b46292168d96f795c69b3e0c5799933b16c4c901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sat, 1 Aug 2020 23:41:46 +0700
Subject: [PATCH 5/8] openjdk14: enable cross compile

Now, native openjdk14 is ready, cross compile openjdk14 for other
architecture.

[skip ci]
Close: #23940
---
 srcpkgs/openjdk14/template | 2 --
 1 file changed, 2 deletions(-)

diff --git a/srcpkgs/openjdk14/template b/srcpkgs/openjdk14/template
index d14547d551d8..867fa07769c3 100644
--- a/srcpkgs/openjdk14/template
+++ b/srcpkgs/openjdk14/template
@@ -47,8 +47,6 @@ shlib_provides="libawt.so libawt_xawt.so libjava.so libjli.so libjvm.so libjawt.
 disable_parallel_build=yes
 build_options="docs"
 
-nocross="until host openjdk14 is available in build server"
-
 # no hotspot JIT for ppc32
 case "$XBPS_TARGET_MACHINE" in
 	ppc64*) ;;

From f141593ef2b9724d3b7036f5d40f723071569bc3 Mon Sep 17 00:00:00 2001
From: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
Date: Sun, 5 Dec 2021 12:46:42 +0100
Subject: [PATCH 6/8] New package: openjdk{12,13,14,15,16}-bootstrap

---
 srcpkgs/openjdk12-bootstrap/template          |   4 +
 srcpkgs/openjdk13-bootstrap/template          |   4 +
 .../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          | 116 ++++++
 .../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          | 112 ++++++
 .../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          | 112 ++++++
 20 files changed, 2082 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
 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
 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/openjdk12-bootstrap/template b/srcpkgs/openjdk12-bootstrap/template
index 104807f1506a..12a517dce3ed 100644
--- a/srcpkgs/openjdk12-bootstrap/template
+++ b/srcpkgs/openjdk12-bootstrap/template
@@ -90,6 +90,10 @@ do_configure() {
 			;;
 	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"
diff --git a/srcpkgs/openjdk13-bootstrap/template b/srcpkgs/openjdk13-bootstrap/template
index 4620da1dd4d0..66d2534e81fa 100644
--- a/srcpkgs/openjdk13-bootstrap/template
+++ b/srcpkgs/openjdk13-bootstrap/template
@@ -90,6 +90,10 @@ do_configure() {
 			;;
 	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"
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..44caa8c58255
--- /dev/null
+++ b/srcpkgs/openjdk14-bootstrap/template
@@ -0,0 +1,116 @@
+# 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="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-2.0-or-later"
+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 -slNp1 -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
+}
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..893fbd1513a5
--- /dev/null
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -0,0 +1,112 @@
+# 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="Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>"
+license="GPL-2.0-or-later"
+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 -slNp1 -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
+}
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..4a30a3fd756c
--- /dev/null
+++ b/srcpkgs/openjdk16-bootstrap/template
@@ -0,0 +1,112 @@
+# 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="Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>"
+license="GPL-2.0-or-later"
+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 -slNp1 -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 35d1b9209ee04428cd610d2f50d9ae18e27a6dbb Mon Sep 17 00:00:00 2001
From: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
Date: Sun, 5 Dec 2021 12:47:49 +0100
Subject: [PATCH 7/8] openjdk14: remove package

---
 srcpkgs/openjdk14-doc                         |   1 -
 srcpkgs/openjdk14-src                         |   1 -
 .../files/musl_patches/aarch64.patch          |  10 -
 .../openjdk14/files/musl_patches/arm.patch    |  21 -
 .../openjdk14/files/musl_patches/build.patch  | 372 ------------------
 .../openjdk14/files/musl_patches/ppc.patch    |  45 ---
 .../openjdk14/files/musl_patches/x86.patch    | 130 ------
 srcpkgs/openjdk14/template                    | 201 ----------
 8 files changed, 781 deletions(-)
 delete mode 120000 srcpkgs/openjdk14-doc
 delete mode 120000 srcpkgs/openjdk14-src
 delete mode 100644 srcpkgs/openjdk14/files/musl_patches/aarch64.patch
 delete mode 100644 srcpkgs/openjdk14/files/musl_patches/arm.patch
 delete mode 100644 srcpkgs/openjdk14/files/musl_patches/build.patch
 delete mode 100644 srcpkgs/openjdk14/files/musl_patches/ppc.patch
 delete mode 100644 srcpkgs/openjdk14/files/musl_patches/x86.patch
 delete mode 100644 srcpkgs/openjdk14/template

diff --git a/srcpkgs/openjdk14-doc b/srcpkgs/openjdk14-doc
deleted file mode 120000
index 1c6fdde19646..000000000000
--- a/srcpkgs/openjdk14-doc
+++ /dev/null
@@ -1 +0,0 @@
-openjdk14
\ No newline at end of file
diff --git a/srcpkgs/openjdk14-src b/srcpkgs/openjdk14-src
deleted file mode 120000
index 1c6fdde19646..000000000000
--- a/srcpkgs/openjdk14-src
+++ /dev/null
@@ -1 +0,0 @@
-openjdk14
\ No newline at end of file
diff --git a/srcpkgs/openjdk14/files/musl_patches/aarch64.patch b/srcpkgs/openjdk14/files/musl_patches/aarch64.patch
deleted file mode 100644
index aa6c5d4d2be2..000000000000
--- a/srcpkgs/openjdk14/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/openjdk14/files/musl_patches/arm.patch b/srcpkgs/openjdk14/files/musl_patches/arm.patch
deleted file mode 100644
index 102428f10f33..000000000000
--- a/srcpkgs/openjdk14/files/musl_patches/arm.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- 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/files/musl_patches/build.patch b/srcpkgs/openjdk14/files/musl_patches/build.patch
deleted file mode 100644
index 60dfdec30abc..000000000000
--- a/srcpkgs/openjdk14/files/musl_patches/build.patch
+++ /dev/null
@@ -1,372 +0,0 @@
---- 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/files/musl_patches/ppc.patch b/srcpkgs/openjdk14/files/musl_patches/ppc.patch
deleted file mode 100644
index d306d501e4b8..000000000000
--- a/srcpkgs/openjdk14/files/musl_patches/ppc.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-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/files/musl_patches/x86.patch b/srcpkgs/openjdk14/files/musl_patches/x86.patch
deleted file mode 100644
index 9c64c189036a..000000000000
--- a/srcpkgs/openjdk14/files/musl_patches/x86.patch
+++ /dev/null
@@ -1,130 +0,0 @@
-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/template b/srcpkgs/openjdk14/template
deleted file mode 100644
index 867fa07769c3..000000000000
--- a/srcpkgs/openjdk14/template
+++ /dev/null
@@ -1,201 +0,0 @@
-# Template file for 'openjdk14'
-_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
-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}/${XBPS_CROSS_TRIPLET}/${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"
-make_build_args="images $(vopt_if docs docs)"
-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="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
-license="GPL-2.0-or-later"
-homepage="http://openjdk.java.net/"
-distfiles="https://hg.openjdk.java.net/jdk-updates/jdk${_java_ver}u/archive/jdk-${version}.tar.gz"
-checksum=dfb3607f1b675458f29a185a40f1dbbf896439cf33b3aa0f3d89df297e604935
-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
-
-case "$XBPS_TARGET_LIBC" in
-	glibc) build_options_default+=" docs";;
-esac
-
-if [ ! "$CROSS_BUILD" ]; then
-	hostmakedepends+=" openjdk13-bootstrap"
-	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk13"
-else
-	hostmakedepends+=" openjdk14"
-	configure_args+=" --with-boot-jdk=/usr/lib/jvm/openjdk14"
-fi
-
-alternatives="
- java:/usr/bin/java:/usr/lib/jvm/openjdk14/bin/java
- java:/usr/bin/jjs:/usr/lib/jvm/openjdk14/bin/jjs
- java:/usr/bin/keytool:/usr/lib/jvm/openjdk14/bin/keytool
- java:/usr/bin/pack200:/usr/lib/jvm/openjdk14/bin/pack200
- java:/usr/bin/rmid:/usr/lib/jvm/openjdk14/bin/rmid
- java:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk14/bin/rmiregistry
- java:/usr/bin/unpack200:/usr/lib/jvm/openjdk14/bin/unpack200
-
- jdk:/usr/bin/jaotc:/usr/lib/jvm/openjdk14/bin/jaotc
- jdk:/usr/bin/jar:/usr/lib/jvm/openjdk14/bin/jar
- jdk:/usr/bin/jarsigner:/usr/lib/jvm/openjdk14/bin/jarsigner
- jdk:/usr/bin/java:/usr/lib/jvm/openjdk14/bin/java
- jdk:/usr/bin/javac:/usr/lib/jvm/openjdk14/bin/javac
- jdk:/usr/bin/javadoc:/usr/lib/jvm/openjdk14/bin/javadoc
- jdk:/usr/bin/javap:/usr/lib/jvm/openjdk14/bin/javap
- jdk:/usr/bin/jcmd:/usr/lib/jvm/openjdk14/bin/jcmd
- jdk:/usr/bin/jconsole:/usr/lib/jvm/openjdk14/bin/jconsole
- jdk:/usr/bin/jdb:/usr/lib/jvm/openjdk14/bin/jdb
- jdk:/usr/bin/jdeprscan:/usr/lib/jvm/openjdk14/bin/jdeprscan
- jdk:/usr/bin/jdeps:/usr/lib/jvm/openjdk14/bin/jdeps
- jdk:/usr/bin/jhsdb:/usr/lib/jvm/openjdk14/bin/jhsdb
- jdk:/usr/bin/jimage:/usr/lib/jvm/openjdk14/bin/jimage
- jdk:/usr/bin/jinfo:/usr/lib/jvm/openjdk14/bin/jinfo
- jdk:/usr/bin/jjs:/usr/lib/jvm/openjdk14/bin/jjs
- jdk:/usr/bin/jlink:/usr/lib/jvm/openjdk14/bin/jlink
- jdk:/usr/bin/jmap:/usr/lib/jvm/openjdk14/bin/jmap
- jdk:/usr/bin/jmod:/usr/lib/jvm/openjdk14/bin/jmod
- jdk:/usr/bin/jps:/usr/lib/jvm/openjdk14/bin/jps
- jdk:/usr/bin/jrunscript:/usr/lib/jvm/openjdk14/bin/jrunscript
- jdk:/usr/bin/jshell:/usr/lib/jvm/openjdk14/bin/jshell
- jdk:/usr/bin/jstack:/usr/lib/jvm/openjdk14/bin/jstack
- jdk:/usr/bin/jstat:/usr/lib/jvm/openjdk14/bin/jstat
- jdk:/usr/bin/jstatd:/usr/lib/jvm/openjdk14/bin/jstatd
- jdk:/usr/bin/keytool:/usr/lib/jvm/openjdk14/bin/keytool
- jdk:/usr/bin/pack200:/usr/lib/jvm/openjdk14/bin/pack200
- jdk:/usr/bin/rmic:/usr/lib/jvm/openjdk14/bin/rmic
- jdk:/usr/bin/rmid:/usr/lib/jvm/openjdk14/bin/rmid
- jdk:/usr/bin/rmiregistry:/usr/lib/jvm/openjdk14/bin/rmiregistry
- jdk:/usr/bin/serialver:/usr/lib/jvm/openjdk14/bin/serialver
- jdk:/usr/bin/unpack200:/usr/lib/jvm/openjdk14/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 -slNp1 -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" ] && [ -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_openjdk14.sh <<-EOF
-	export JAVA_HOME=\${JAVA_HOME=/$_jdk_home}
-	EOF
-	vlicense ASSEMBLY_EXCEPTION
-	vlicense LICENSE
-}
-
-openjdk14-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
-	}
-}
-
-openjdk14-src_package() {
-	nostrip=yes
-	noverifyrdeps=yes
-	noshlibprovides=yes
-	short_desc+=" -- sources"
-	pkg_install() {
-		vmove "$_jdk_home/lib/src.zip"
-	}
-}

From 53ab5f5548c2f4d016be55a680c348339d47049a Mon Sep 17 00:00:00 2001
From: Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>
Date: Sun, 5 Dec 2021 12:49:01 +0100
Subject: [PATCH 8/8] New package: openjdk17-17.0.1+12

---
 common/shlibs                                 |   6 +
 srcpkgs/openjdk17-doc                         |   1 +
 srcpkgs/openjdk17-src                         |   1 +
 srcpkgs/openjdk17-static-libs                 |   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                    | 202 ++++++++++
 10 files changed, 789 insertions(+)
 create mode 120000 srcpkgs/openjdk17-doc
 create mode 120000 srcpkgs/openjdk17-src
 create mode 120000 srcpkgs/openjdk17-static-libs
 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 ab865cc085d2..21da7bfe1ad2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1810,6 +1810,12 @@ libawt_xawt.so openjdk11-11.0.5+10_1
 libjava.so openjdk11-11.0.5+10_1
 libjli.so openjdk11-11.0.5+10_1
 libjvm.so openjdk11-11.0.5+10_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 openjdk7-bootstrap-7u221b02_1
 libawt.so openjdk7-bootstrap-7u221b02_1
 libawt_xawt.so openjdk7-bootstrap-7u221b02_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-static-libs b/srcpkgs/openjdk17-static-libs
new file mode 120000
index 000000000000..99ab1cb1b0d2
--- /dev/null
+++ b/srcpkgs/openjdk17-static-libs
@@ -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..89ebb47950e0
--- /dev/null
+++ b/srcpkgs/openjdk17/template
@@ -0,0 +1,202 @@
+# 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="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-2.0-or-later"
+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 -slNp1 -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] 3+ messages in thread

* Re: [WIP] Openjdk17
  2021-12-05 12:05 [PR PATCH] [WIP] Openjdk17 raedwulf
@ 2022-02-11 22:43 ` leahneukirchen
  2022-02-11 22:43 ` [PR PATCH] [Closed]: " leahneukirchen
  1 sibling, 0 replies; 3+ messages in thread
From: leahneukirchen @ 2022-02-11 22:43 UTC (permalink / raw)
  To: ml

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

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/34390#issuecomment-1036703270

Comment:
Done in #34989.

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

* Re: [PR PATCH] [Closed]: [WIP] Openjdk17
  2021-12-05 12:05 [PR PATCH] [WIP] Openjdk17 raedwulf
  2022-02-11 22:43 ` leahneukirchen
@ 2022-02-11 22:43 ` leahneukirchen
  1 sibling, 0 replies; 3+ messages in thread
From: leahneukirchen @ 2022-02-11 22:43 UTC (permalink / raw)
  To: ml

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

There's a closed pull request on the void-packages repository

[WIP] Openjdk17
https://github.com/void-linux/void-packages/pull/34390

Description:
This is open for feedback/other contributions because I don't really have the time to maintain this.
I've tested it only on x86-64 so there's a high chance that the musl patches are broken.

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

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

#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)

[ci skip]

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

end of thread, other threads:[~2022-02-11 22:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-05 12:05 [PR PATCH] [WIP] Openjdk17 raedwulf
2022-02-11 22:43 ` leahneukirchen
2022-02-11 22:43 ` [PR PATCH] [Closed]: " 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).