gentoo-bootstrap/dev-java/openjdk/files/openjdk9-hotspot-musl.patch

184 lines
5.7 KiB
Diff

--- openjdk.orig/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -73,7 +73,6 @@
# include <pwd.h>
# include <poll.h>
# include <ucontext.h>
-# include <fpu_control.h>
#ifdef AMD64
#define REG_SP REG_RSP
@@ -532,6 +531,9 @@
ShouldNotReachHere();
}
+
+#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
+#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
void os::Linux::init_thread_fpu_state(void) {
#ifndef AMD64
--- openjdk.orig/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
+++ openjdk/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
@@ -75,7 +75,7 @@
# include <pwd.h>
# include <poll.h>
# include <ucontext.h>
-# include <fpu_control.h>
+# include <linux/types.h> /* provides __u64 */
#ifdef BUILTIN_SIM
#define REG_SP REG_RSP
--- openjdk.orig/hotspot/src/jdk.hotspot.agent/linux/native/libsaproc/proc_service.h 2018-01-22 15:19:02.000000000 +0000
+++ openjdk/hostspot/src/jdk.hotspot.agent/linux/native/libsaproc/proc_service.h 2020-10-12 12:56:27.323706510 +0000
@@ -26,7 +26,7 @@
#define _PROC_SERVICE_H_
#include <stdio.h>
-#include <thread_db.h>
+#include <sys/procfs.h>
// Linux does not have the proc service library, though it does provide the
// thread_db library which can be used to manipulate threads without having
@@ -43,34 +43,4 @@
PS_NOFREGS /* FPU register set not available for given lwp */
} ps_err_e;
-// ps_getpid() is only defined on Linux to return a thread's process ID
-pid_t ps_getpid(struct ps_prochandle *ph);
-
-// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
-// of the load object object_name in the target process identified by ph.
-// It returns the symbol's value as an address in the target process in
-// *sym_addr.
-
-ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
- const char *sym_name, psaddr_t *sym_addr);
-
-// read "size" bytes of data from debuggee at address "addr"
-ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t addr,
- void *buf, size_t size);
-
-// write "size" bytes of data to debuggee at address "addr"
-ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr,
- const void *buf, size_t size);
-
-ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lid, const prfpregset_t *fpregs);
-
-ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lid, const prgregset_t gregset);
-
-ps_err_e ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lid, prfpregset_t *fpregs);
-
-ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset);
-
-// new libthread_db of NPTL seem to require this symbol
-ps_err_e ps_get_thread_area();
-
#endif /* _PROC_SERVICE_H_ */
--- openjdk.orig/hotspot/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c 2018-01-22 15:19:02.000000000 +0000
+++ openjdk/hotspot/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c 2020-10-12 13:00:33.143035725 +0000
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include <thread_db.h>
+#include <dirent.h>
#include "libproc_impl.h"
#define SA_ALTROOT "SA_ALTROOT"
@@ -116,11 +116,13 @@
// init debug mode
_libsaproc_debug = debug;
+#ifdef INCLUDE_SA_ATTACH
// initialize the thread_db library
if (td_init() != TD_OK) {
print_debug("libthread_db's td_init failed\n");
return false;
}
+#endif
return true;
}
@@ -273,6 +275,7 @@
}
+#ifdef INCLUDE_SA_ATTACH
// struct used for client data from thread_db callback
struct thread_db_client_data {
struct ps_prochandle* ph;
@@ -299,9 +302,11 @@
return TD_OK;
}
+#endif
// read thread_info using libthread_db
bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb) {
+#ifdef INCLUDE_SA_ATTACH
struct thread_db_client_data mydata;
td_thragent_t* thread_agent = NULL;
if (td_ta_new(ph, &thread_agent) != TD_OK) {
@@ -322,6 +327,30 @@
// delete thread agent
td_ta_delete(thread_agent);
+#else
+ DIR *dir = NULL;
+ struct dirent *ent = NULL;
+ char taskpath[80];
+ pid_t pid = ph->pid;
+
+ // Find the lwpids to attach to by traversing the /proc/<pid>/task/ directory.
+ snprintf(taskpath, sizeof (taskpath), "/proc/%ld/task", (unsigned long)pid);
+ if ((dir = opendir(taskpath)) != NULL) {
+ while ((ent = readdir(dir)) != NULL) {
+ unsigned long lwp;
+
+ if ((lwp = strtoul(ent->d_name, NULL, 10)) != 0) {
+ // Create and add the thread info.
+ (*cb)(ph, 0, lwp);
+ }
+ }
+ } else {
+ print_debug("Could not open /proc/%ld/task.\n", (unsigned long)pid);
+ return false;
+ }
+
+ closedir(dir);
+#endif
return true;
}
diff -U3 -r openjdk-9.0.4_p12/work/hotspot-jdk-9.0.4+12/make/lib/Lib-jdk.hotspot.agent.gmk openjdk-9.0.4_p12.orig/work/hotspot-jdk-9.0.4+12/make/lib/Lib-jdk.hotspot.agent.gmk
--- openjdk.orig/hotspot/make/lib/Lib-jdk.hotspot.agent.gmk 2018-01-22 15:19:02.000000000 +0000
+++ openjdk/hotspot/make/lib/Lib-jdk.hotspot.agent.gmk 2020-10-12 13:03:00.569605599 +0000
@@ -57,7 +57,10 @@
SA_CFLAGS := $(CFLAGS_JDKLIB) -D_FILE_OFFSET_BITS=64 \
$(SA_MACHINE_FLAG_linux)
SA_LDFLAGS := $(LDFLAGS_JDKLIB) $(SA_MACHINE_FLAG_linux)
- SA_LIBS := -lthread_db $(LIBDL)
+ SA_LIBS := $(LIBDL)
+ ifeq ($(INCLUDE_SA_ATTACH), true)
+ SA_LIBS += -lthread_db
+ endif
else ifeq ($(OPENJDK_TARGET_OS), solaris)
SA_TOOLCHAIN := TOOLCHAIN_LINK_CXX
@@ -95,6 +98,13 @@
endif
endif
+ifeq ($(INCLUDE_SA_ATTACH), true)
+ SA_CFLAGS += -DINCLUDE_SA_ATTACH
+endif
+
+SA_CFLAGS += -DLIBC=\"$(OPENJDK_TARGET_LIBC)\"
+
+
################################################################################
$(eval $(call SetupNativeCompilation, BUILD_LIBSA, \