summaryrefslogtreecommitdiff
path: root/Ports/OpenJDK/patches/0001-make-Add-Serenity-support-masquerading-as-BSD-when-n.patch
blob: 31f395c98e049bfb09d9413de3ea46a9005e65e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Timur Sultanov <SultanovTS@yandex.ru>
Date: Wed, 16 Feb 2022 21:04:18 +0300
Subject: [PATCH] make: Add Serenity support, masquerading as BSD when
 necessary

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
---
 make/autoconf/flags-cflags.m4                |  3 +++
 make/autoconf/flags-ldflags.m4               | 11 +++++++++++
 make/autoconf/platform.m4                    |  8 ++++++++
 make/autoconf/toolchain.m4                   |  1 +
 make/common/modules/LauncherCommon.gmk       |  3 +++
 make/hotspot/lib/JvmMapfile.gmk              | 12 ++++++++++++
 make/modules/java.base/lib/CoreLibraries.gmk |  1 +
 7 files changed, 39 insertions(+)

diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4
index 5eed1138f1f205874e21b92050634fbfcfefd0c7..62e53a1c421c600ed92eaeb6805fd61e825e3072 100644
--- a/make/autoconf/flags-cflags.m4
+++ b/make/autoconf/flags-cflags.m4
@@ -382,6 +382,9 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
     CFLAGS_OS_DEF_JVM="-DAIX"
   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
+  elif test "x$OPENJDK_TARGET_OS" = xserenity; then
+    CFLAGS_OS_DEF_JDK="-DSERENITY"
+    CFLAGS_OS_DEF_JVM="-DSERENITY"
   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
     CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
   fi
diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4
index 23bb33e878d17d2b8072189c1c6d4b17097598e7..e3deb0c3fb0cecfb39b4052f0e5abda34465abc9 100644
--- a/make/autoconf/flags-ldflags.m4
+++ b/make/autoconf/flags-ldflags.m4
@@ -110,6 +110,17 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
     fi
   fi
 
+  if test "x$OPENJDK_TARGET_OS" = xserenity; then
+    if test "x$TOOLCHAIN_TYPE" = xgcc; then
+      # FIXME: -lgcc_s should not be required, toolchain spec file issue
+      OS_LDFLAGS_JVM_ONLY="$OS_LDFLAGS_JVM_ONLY -ldl -lpthread -lgcc_s"
+      OS_LDFLAGS="$OS_LDFLAGS -ldl -lpthread -lgcc_s"
+    elif test "x$TOOLCHAIN_TYPE" = xclang; then
+      OS_LDFLAGS_JVM_ONLY="$OS_LDFLAGS_JVM_ONLY -ldl -lpthread"
+      OS_LDFLAGS="$OS_LDFLAGS -ldl -lpthread"
+    fi
+  fi
+
   # Setup debug level-dependent LDFLAGS
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
diff --git a/make/autoconf/platform.m4 b/make/autoconf/platform.m4
index 205d64f566d93a9a9c9d0b9191372e3aabb05143..6e668edc45672128a3e70bb4e37d0100a1ef9243 100644
--- a/make/autoconf/platform.m4
+++ b/make/autoconf/platform.m4
@@ -220,6 +220,10 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
       VAR_OS=aix
       VAR_OS_TYPE=unix
       ;;
+    *serenity*)
+      VAR_OS=serenity
+      VAR_OS_TYPE=unix
+      ;;
     *)
       AC_MSG_ERROR([unsupported operating system $1])
       ;;
@@ -521,6 +525,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
   HOTSPOT_$1_OS=${OPENJDK_$1_OS}
   if test "x$OPENJDK_$1_OS" = xmacosx; then
     HOTSPOT_$1_OS=bsd
+  elif test "x$OPENJDK_$1_OS" = xserenity; then
+    HOTSPOT_$1_OS=bsd
   fi
   AC_SUBST(HOTSPOT_$1_OS)
 
@@ -587,6 +593,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
     OPENJDK_$1_OS_INCLUDE_SUBDIR="win32"
   elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
     OPENJDK_$1_OS_INCLUDE_SUBDIR="darwin"
+  elif test "x$OPENJDK_TARGET_OS" = "xserenity"; then
+    OPENJDK_$1_OS_INCLUDE_SUBDIR="bsd"
   fi
   AC_SUBST(OPENJDK_$1_OS_INCLUDE_SUBDIR)
 ])
diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4
index 69540e1608e1df16ca2a3e631c061ba6ae366ca7..badd84a506a201d664f0a6902c68109017c86180 100644
--- a/make/autoconf/toolchain.m4
+++ b/make/autoconf/toolchain.m4
@@ -42,6 +42,7 @@ VALID_TOOLCHAINS_linux="gcc clang"
 VALID_TOOLCHAINS_macosx="gcc clang"
 VALID_TOOLCHAINS_aix="xlc"
 VALID_TOOLCHAINS_windows="microsoft"
+VALID_TOOLCHAINS_serenity="gcc clang"
 
 # Toolchain descriptions
 TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk
index 7ad0375e2e38ff31419eb47d028a652c2dead647..8100f655e9273de3775e828d7c9dc8aa0185bf46 100644
--- a/make/common/modules/LauncherCommon.gmk
+++ b/make/common/modules/LauncherCommon.gmk
@@ -157,11 +157,14 @@ define SetupBuildLauncherBody
           $$($1_LDFLAGS), \
       LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib) \
           -L$(call FindLibDirForModule, java.base), \
+      LDFLAGS_serenity := $$(call SET_EXECUTABLE_ORIGIN,/../lib) \
+          -L$(call FindLibDirForModule, java.base), \
       LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN,/../lib) \
           -L$(call FindLibDirForModule, java.base), \
       LDFLAGS_aix := -L$(SUPPORT_OUTPUTDIR)/native/java.base, \
       LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \
       LIBS_linux := -ljli -lpthread $(LIBDL), \
+      LIBS_serenity := -ljli -lpthread $(LIBDL), \
       LIBS_macosx := -ljli -framework Cocoa -framework Security \
           -framework ApplicationServices, \
       LIBS_aix := -ljli_static, \
diff --git a/make/hotspot/lib/JvmMapfile.gmk b/make/hotspot/lib/JvmMapfile.gmk
index 5cba93178c744feb0d1c0286634a40def232eca2..752727d0d8b445ab584a09ee5e0cd3f65f9813d4 100644
--- a/make/hotspot/lib/JvmMapfile.gmk
+++ b/make/hotspot/lib/JvmMapfile.gmk
@@ -64,6 +64,18 @@ ifeq ($(call isTargetOs, linux), true)
         if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \
       }'
 
+else ifeq ($(call isTargetOs, serenity), true)
+  DUMP_SYMBOLS_CMD := $(NM) --defined-only *.o
+  ifneq ($(FILTER_SYMBOLS_PATTERN), )
+    FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|
+  endif
+  FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)^_ZTV|^gHotSpotVM|^UseSharedSpaces$$
+  FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|^_ZN9Arguments17SharedArchivePathE$$
+  FILTER_SYMBOLS_AWK_SCRIPT := \
+      '{ \
+        if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \
+      }'
+
 else ifeq ($(call isTargetOs, macosx), true)
   # nm on macosx prints out "warning: nm: no name list" to stderr for
   # files without symbols. Hide this, even at the expense of hiding real errors.
diff --git a/make/modules/java.base/lib/CoreLibraries.gmk b/make/modules/java.base/lib/CoreLibraries.gmk
index 1d5fede2aa8af9e475ab2980e303b3ff22412795..0a61d009f34a4e73ace746d0cc6068fe2852e832 100644
--- a/make/modules/java.base/lib/CoreLibraries.gmk
+++ b/make/modules/java.base/lib/CoreLibraries.gmk
@@ -209,6 +209,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
     LIBS_unix := $(LIBZ_LIBS), \
     LIBS_linux := $(LIBDL) -lpthread, \
     LIBS_aix := $(LIBDL),\
+    LIBS_serenity := $(LIBDL) -lpthread, \
     LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
     LIBS_windows := advapi32.lib comctl32.lib user32.lib, \
 ))