ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ozone/mgar/pkg/openjdk8/jdk8-patch.py
Revision: 43
Committed: Wed Jun 24 17:14:55 2026 UTC (3 weeks, 5 days ago) by operz
Content type: text/x-python
File size: 6736 byte(s)
Log Message:
openjdk7,openjdk8: switch from Sun Studio to GCC 12.5.0; add toolchain/flag patch scripts

File Contents

# Content
1 #!/usr/bin/env /opt/ozsw/bin/python3
2 """Patch JDK 8 source for GCC build on Solaris."""
3 import sys, os
4
5 if len(sys.argv) != 2:
6 print('Usage: %s WORKSRC' % sys.argv[0])
7 sys.exit(1)
8
9 WORKSRC = sys.argv[1]
10
11 def patch(path, old, new, required=True):
12 with open(path, 'r') as f:
13 content = f.read()
14 if old not in content:
15 if required:
16 print('PATCH FAILED (old not found): %s' % path)
17 print('Looking for: %r' % old[:100])
18 sys.exit(1)
19 else:
20 print('SKIP (already patched?): %s' % path)
21 return
22 content = content.replace(old, new, 1)
23 with open(path, 'w') as f:
24 f.write(content)
25 print('OK: %s' % os.path.relpath(path, WORKSRC))
26
27 # ===== 1. toolchain.m4: allow gcc on Solaris =====
28 tm = os.path.join(WORKSRC, 'common/autoconf/toolchain.m4')
29 patch(tm,
30 'VALID_TOOLCHAINS_solaris="solstudio"',
31 'VALID_TOOLCHAINS_solaris="solstudio gcc"')
32
33 # ===== 2. generated-configure.sh: allow gcc on Solaris =====
34 gc = os.path.join(WORKSRC, 'common/autoconf/generated-configure.sh')
35 patch(gc,
36 'VALID_TOOLCHAINS_solaris="solstudio"',
37 'VALID_TOOLCHAINS_solaris="solstudio gcc"')
38
39 # ===== 3. generated-configure.sh: fix OPENWIN_HOME for /opt/ozsw X11 =====
40 patch(gc,
41 ' OPENWIN_HOME="/usr/openwin"\n'
42 ' X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"\n'
43 ' X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
44 ' -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
45 ' -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
46 ' -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"',
47
48 ' OPENWIN_HOME="/opt/ozsw"\n'
49 ' X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"\n'
50 ' X_LIBS="-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
51 ' -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"')
52
53 # ===== 4. libraries.m4: fix OPENWIN_HOME for /opt/ozsw X11 =====
54 lm = os.path.join(WORKSRC, 'common/autoconf/libraries.m4')
55 patch(lm,
56 ' OPENWIN_HOME="/usr/openwin"\n'
57 ' X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"\n'
58 ' X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
59 ' -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
60 ' -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
61 ' -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"',
62
63 ' OPENWIN_HOME="/opt/ozsw"\n'
64 ' X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"\n'
65 ' X_LIBS="-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \\\n'
66 ' -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"')
67
68 # ===== 5. assembler_solaris_x86.cpp: add 32-bit guards =====
69 asm = os.path.join(WORKSRC,
70 'hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86.cpp')
71 patch(asm,
72 '#include "runtime/thread.inline.hpp"\n'
73 '\n'
74 'void MacroAssembler::int3() {\n'
75 ' push(rax);\n'
76 ' push(rdx);\n'
77 ' push(rcx);\n'
78 ' call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));\n'
79 ' pop(rcx);\n'
80 ' pop(rdx);\n'
81 ' pop(rax);\n'
82 '}\n'
83 '\n'
84 'void MacroAssembler::get_thread(Register thread) {\n'
85 ' if (thread != rax) {\n'
86 ' push(rax);\n'
87 ' }\n'
88 ' push(rdi);\n'
89 ' push(rsi);\n'
90 ' push(rdx);\n'
91 ' push(rcx);\n'
92 ' push(r8);\n'
93 ' push(r9);\n'
94 ' push(r10);\n'
95 ' push(r11);\n'
96 '\n'
97 ' call(RuntimeAddress(CAST_FROM_FN_PTR(address, ThreadLocalStorage::thread)));\n'
98 '\n'
99 ' pop(r11);\n'
100 ' pop(r10);\n'
101 ' pop(r9);\n'
102 ' pop(r8);\n'
103 ' pop(rcx);\n'
104 ' pop(rdx);\n'
105 ' pop(rsi);\n'
106 ' pop(rdi);\n'
107 ' if (thread != rax) {\n'
108 ' movl(thread, rax);\n'
109 ' pop(rax);\n'
110 ' }\n'
111 '}',
112
113 '#include "runtime/thread.inline.hpp"\n'
114 '\n'
115 '#ifndef _LP64\n'
116 'void MacroAssembler::int3() {\n'
117 ' call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));\n'
118 '}\n'
119 '\n'
120 'void MacroAssembler::get_thread(Register thread) {\n'
121 ' if (thread != rax) push(rax);\n'
122 ' push(rcx);\n'
123 ' push(rdx);\n'
124 ' call(RuntimeAddress(CAST_FROM_FN_PTR(address, ThreadLocalStorage::thread)));\n'
125 ' pop(rdx);\n'
126 ' pop(rcx);\n'
127 ' if (thread != rax) movl(thread, rax);\n'
128 ' if (thread != rax) pop(rax);\n'
129 '}\n'
130 '#else\n'
131 'void MacroAssembler::int3() {\n'
132 ' push(rax);\n'
133 ' push(rdx);\n'
134 ' push(rcx);\n'
135 ' call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));\n'
136 ' pop(rcx);\n'
137 ' pop(rdx);\n'
138 ' pop(rax);\n'
139 '}\n'
140 '\n'
141 'void MacroAssembler::get_thread(Register thread) {\n'
142 ' if (thread != rax) {\n'
143 ' push(rax);\n'
144 ' }\n'
145 ' push(rdi);\n'
146 ' push(rsi);\n'
147 ' push(rdx);\n'
148 ' push(rcx);\n'
149 ' push(r8);\n'
150 ' push(r9);\n'
151 ' push(r10);\n'
152 ' push(r11);\n'
153 '\n'
154 ' call(RuntimeAddress(CAST_FROM_FN_PTR(address, ThreadLocalStorage::thread)));\n'
155 '\n'
156 ' pop(r11);\n'
157 ' pop(r10);\n'
158 ' pop(r9);\n'
159 ' pop(r8);\n'
160 ' pop(rcx);\n'
161 ' pop(rdx);\n'
162 ' pop(rsi);\n'
163 ' pop(rdi);\n'
164 ' if (thread != rax) {\n'
165 ' movl(thread, rax);\n'
166 ' pop(rax);\n'
167 ' }\n'
168 '}\n'
169 '#endif',
170 required=False)
171
172 # ===== 6. superword.hpp: abs -> ::labs for jlong =====
173 sw = os.path.join(WORKSRC,
174 'hotspot/src/share/vm/opto/superword.hpp')
175 patch(sw,
176 'jlong difference = abs(java_subtract((jlong)_offset, (jlong)q._offset));',
177 'jlong difference = ::labs(java_subtract((jlong)_offset, (jlong)q._offset));',
178 required=False)
179
180 # ===== 7. gif_lib.h: bool fallback before stdbool.h =====
181 gf = os.path.join(WORKSRC,
182 'jdk/src/share/native/sun/awt/giflib/gif_lib.h')
183 patch(gf,
184 '/** Begin JDK modifications to support building using old compilers**/\n'
185 '#ifndef _WIN32\n'
186 '#include <stdbool.h>',
187 '/** Begin JDK modifications to support building using old compilers**/\n'
188 '/* Solaris workaround: stdbool.h is empty in -xc99=%none mode */\n'
189 '#ifndef __bool_true_false_are_defined\n'
190 '#define bool int\n'
191 '#define true 1\n'
192 '#define false 0\n'
193 '#define __bool_true_false_are_defined 1\n'
194 '#endif\n'
195 '#ifndef _WIN32\n'
196 '#include <stdbool.h>',
197 required=False)
198
199 # ===== 8. mapfile-x86: remove _IO_stdin_used =====
200 mf = os.path.join(WORKSRC,
201 'jdk/make/mapfiles/launchers/mapfile-x86')
202 patch(mf,
203 '\t_IO_stdin_used;\n',
204 '',
205 required=False)
206
207 print('All patches applied successfully.')