-
Notifications
You must be signed in to change notification settings - Fork 16
/
build8.sh
executable file
·379 lines (311 loc) · 9.17 KB
/
build8.sh
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/bash
set -e
BUILD_LOG="LOG=debug"
BUILD_MODE=dev
TEST_JDK=false
BUILD_JAVAFX=false
# set to true to alway reconfigure the build (recommended that CLEAN_BUILD also be set true)
RECONFIGURE_BUILD=true
# set to true to always clean the build
CLEAN_BUILD=true
# set to true to always revert patches
REVERT_PATCHES=false
export BUILD_TARGET_ARCH=arm64
#export BUILD_TARGET_ARCH=x86_64
# if we're on a macos m1 machine, we can run in x86_64 or native aarch64/arm64 mode.
# currently the build script only supports building x86_64 binaries and only on x86_64 hosts.
if [ "`uname`" = "Darwin" ] ; then
if [ "`uname -m`" != "$BUILD_TARGET_ARCH" ] ; then
if [ "`uname -m`" = "arm64" ] ; then
echo "building on ARM - restarting in Intel mode"
arch -x86_64 "$0" $@
exit $?
else
echo "running on Intel - can't restart to ARM mode"
exit 99
fi
fi
fi
if [ "X$BUILD_MODE" == "X" ] ; then
# normal, dev, shenandoah, [jvmci, eventually]
BUILD_MODE=normal
fi
## release, fastdebug, slowdebug
if [ "X$DEBUG_LEVEL" == "X" ] ; then
DEBUG_LEVEL=fastdebug
fi
## build directory
if [ "X$BUILD_DIR" == "X" ] ; then
BUILD_DIR=`pwd`
fi
## add javafx to build at end
if [ "X$BUILD_JAVAFX" == "X" ] ; then
BUILD_JAVAFX=false
fi
BUILD_SCENEBUILDER=$BUILD_JAVAFX
### no need to change anything below this line unless something went wrong
set_os() {
IS_LINUX=false
IS_DARWIN=false
if [ "`uname`" = "Linux" ] ; then
IS_LINUX=true
fi
IS_DARWIN=false
if [ "`uname`" = "Darwin" ] ; then
IS_DARWIN=true
fi
}
set_os
if [ "$BUILD_MODE" == "normal" ] ; then
JDK_BASE=jdk8u
BUILD_MODE=dev
JDK_REPO=https://github.com/openjdk/$JDK_BASE.git
JDK_DIR="$BUILD_DIR/$JDK_BASE"
elif [ "$BUILD_MODE" == "dev" ] ; then
JDK_BASE=jdk8u-dev
BUILD_MODE=dev
JDK_REPO=https://github.com/openjdk/$JDK_BASE.git
JDK_DIR="$BUILD_DIR/$JDK_BASE"
elif [ "$BUILD_MODE" == "shenandoah" ] ; then
JDK_BASE=jdk8u
BUILD_MODE=dev
JDK_REPO=https://github.com/openjdk/shenandoah-jdk8u-dev
JDK_DIR="$BUILD_DIR/$JDK_BASE-shenandoah"
fi
# define build environment
pushd `dirname $0`
SCRIPT_DIR=`pwd`
PATCH_DIR="$SCRIPT_DIR/jdk8u-patch"
TOOL_DIR="$BUILD_DIR/tools_$BUILD_TARGET_ARCH"
TMP_DIR="$TOOL_DIR/tmp"
popd
if $IS_DARWIN ; then
JDK_CONF=macosx-${BUILD_TARGET_ARCH}-normal-server-$DEBUG_LEVEL
else
JDK_CONF=linux-${BUILD_TARGET_ARCH}-normal-server-$DEBUG_LEVEL
fi
### JDK
downloadjdksrc() {
if [ ! -d "$JDK_DIR" ]; then
progress "clone $JDK_REPO to $JDK_DIR"
pushd "$BUILD_DIR"
git clone $JDK_REPO "$JDK_DIR"
popd
fi
pushd "$JDK_DIR"
chmod 755 configure
popd
}
print_jdk_repo_id() {
pushd "$JDK_DIR"
progress "JDK base repo: `git log -1`"
popd
}
applypatch() {
cd "$JDK_DIR/$1"
echo "applying $1 $2"
patch -p1 <$2
}
patch_linux_jdkbuild() {
progress "patch jdk"
# fix WARNINGS_ARE_ERRORS handling
applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-8241285.patch"
}
patch_linux_jdkquality() {
progress "patch test failures (no patches available at this time)"
}
patch_macos_jdkbuild() {
progress "patch jdk"
# only one patch currently enabled!
# fix version check to allow Xcode 13
applypatch . "$PATCH_DIR/allow-xcode13.patch"
# JDK-8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
# applypatch . "$PATCH_DIR/jdk8u-8019470.patch"
# fix WARNINGS_ARE_ERRORS handling
# applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-8241285.patch"
# fix some help messages and Xcode version checks
# applypatch . "$PATCH_DIR/jdk8u-buildfix1.patch"
# use correct C++ standard library
# #applypatch . "$PATCH_DIR/jdk8u-libcxxfix.patch"
# misc clang-specific cleanup
# applypatch . "$PATCH_DIR/jdk8u-buildfix2.patch"
# misc clang-specific cleanup; doesn't apply cleanly on top of 8019470
# (use -g1 for fastdebug builds)
#applypatch . "$PATCH_DIR/jdk8u-buildfix2a.patch"
# fix for clang crash if base has non-virtual destructor
# applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-8244878.patch"
# applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-mac.patch"
# libosxapp.dylib fails to build on Mac OS 10.9 with clang
# applypatch jdk "$PATCH_DIR/jdk8u-jdk-8043646.patch"
# applypatch jdk "$PATCH_DIR/jdk8u-jdk-minversion.patch"
# c99 and macosx fixes
# applypatch . "$PATCH_DIR/jdk8u-c99.patch"
# applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-c99.patch"
# applypatch jdk "$PATCH_DIR/jdk8u-jdk-c99.patch"
}
patch_macos_jdkquality() {
progress "patch jdk test failures"
# disable optimization on some files when using clang
# (should check if this is still tha case on newer clang)
# applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-8138820.patch"
# this patch is incomplete in 8u; it doesn't properly access some test support classes:
# applypatch jdk "$PATCH_DIR/jdk8u-jdk-8210403.patch"
# 8144125: [macOS] java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java failed automatically
# (rejected as it doen't seem to apply to 8u without lots more work; the test fails either way)
# applypatch jdk "$PATCH_DIR/jdk8u-jdk-8144125.patch"
}
patch_jdk() {
if $IS_LINUX ; then
patch_linux_jdkbuild
patch_linux_jdkquality
fi
if $IS_DARWIN ; then
echo not done: patch_macos_jdkbuild
# patch_macos_jdkquality
fi
}
deleteunknown() {
cd "$2"
git status | grep ^\? | cut -c 3- | while IFS= read -r fn ; do
echo deleting "$1/$fn"
rm "$fn"
done
}
deleteallunknown() {
deleteunknown . "$JDK_DIR"
}
revertjdk() {
cd "$JDK_DIR"
git restore .
deleteallunknown
find "$JDK_DIR" -type f -name \*.orig -o -name \*.rej -print -delete
}
cleanjdk() {
progress "clean jdk"
rm -fr "$JDK_DIR/build"
find "$JDK_DIR" -type f -name \*.orig -o -name \*.rej -print -delete
}
configurejdk() {
progress "configure jdk"
#if [ $XCODE_VERSION -ge 11 ] ; then
# DISABLE_PCH=--disable-precompiled-headers
#fi
pushd "$JDK_DIR"
chmod 755 ./configure
unset DARWIN_CONFIG
if $IS_DARWIN ; then
BOOT_JDK="$TOOL_DIR/jdk8_$BUILD_TARGET_ARCH/Contents/Home"
DARWIN_CONFIG="--with-toolchain-type=clang \
--with-xcode-path="$XCODE_APP" \
--includedir="$XCODE_DEVELOPER_PREFIX/Toolchains/XcodeDefault.xctoolchain/usr/include" \
--with-boot-jdk="$BOOT_JDK""
fi
if $BUILD_JAVAFX ; then
# the javafx build requires 1.8.0-b40 or higher
BUILD_VERSION_CONFIG="--with-build-number=b88 \
--with-vendor-name="openjdk" \
--with-milestone="ea" \
--with-update-version=99"
fi
#./configure --help
./configure $DARWIN_CONFIG $BUILD_VERSION_CONFIG \
--with-debug-level=$DEBUG_LEVEL \
--with-conf-name=$JDK_CONF \
--with-native-debug-symbols=external \
--with-jtreg="$TOOL_DIR/jtreg" \
--openjdk-target=aarch64-apple-darwin \
--with-freetype-include="$TOOL_DIR/freetype/include" \
--with-freetype-lib=$TOOL_DIR/freetype/objs/.libs $DISABLE_PCH
popd
}
buildjdk() {
progress "build jdk"
pushd "$JDK_DIR"
make images $BUILD_LOG COMPILER_WARNINGS_FATAL=false CONF=$JDK_CONF
if $IS_DARWIN ; then
# seems the path handling has changed; use rpath instead of hardcoded path
find "$JDK_DIR/build/$JDK_CONF/images" -type f -name libfontmanager.dylib -exec install_name_tool -change /usr/local/lib/libfreetype.6.dylib @rpath/libfreetype.dylib.6 {} \; -print
fi
popd
}
dojtreg() {
REPO=$1
shift
TESTS=$*
JDK_HOME="$JDK_DIR/build/$JDK_CONF/images/j2sdk-image"
JT_WORK="$BUILD_DIR/jtreg"
pushd "$JDK_DIR/$REPO"
set +e
jtreg -w "$JT_WORK/work" -r "$JT_WORK/report" -jdk:$JDK_HOME $TESTS
set -e
popd
}
testjdk() {
progress "test jdk"
pushd "$JDK_DIR"
#JT_HOME="$TOOL_DIR/jtreg" make test TEST="jdk_util"
JT_HOME="$TOOL_DIR/jtreg" make test TEST="jdk_awt"
#JT_HOME="$TOOL_DIR/jtreg" make test TEST="hotspot_tier1"
#JT_HOME="$TOOL_DIR/jtreg" make test TEST="jdk_tier1"
popd
}
progress() {
echo $1
}
#### build the world
progress "building in $JDK_DIR"
set_os
download_tools() {
progress "download tools"
export BUILD_TARGET_ARCH
if $IS_DARWIN ; then
. "$SCRIPT_DIR/tools.sh" "$TOOL_DIR" freetype autoconf bootstrap_jdk8 jtreg xcode_jnf
else
. "$SCRIPT_DIR/tools.sh" "$TOOL_DIR" freetype jtreg
fi
}
JDK_IMAGE_DIR="$JDK_DIR/build/$JDK_CONF/images/j2sdk-image"
# must always download tools to set paths properly
download_tools
set -x
if [ ! -d "$JDK_DIR" ]; then
echo "no local JDK source repo"
downloadjdksrc
print_jdk_repo_id
REVERT_PATCHES=true
RECONFIGURE_BUILD=true
CLEAN_BUILD=false
elif [ ! -d "$JDK_DIR/build" ] ; then
RECONFIGURE_BUILD=true
fi
if $CLEAN_BUILD ; then
cleanjdk
fi
if $REVERT_PATCHES ; then
revertjdk
patch_jdk
fi
if [ $RECONFIGURE_BUILD -o $CLEAN_BUILD ] ; then
configurejdk
fi
buildjdk
if $TEST_JDK ; then
#dojtreg jdk test/java/awt/event/ComponentEvent/MovedResizedTwiceTest
#dojtreg jdk test/java/awt/image/Raster/TestChildRasterOp.java test/java/awt/event/KeyEvent/SwallowKeyEvents test/java/awt/event/KeyEvent/KeyChar/KeyCharTest.java
testjdk
fi
progress "create distribution zip"
if $BUILD_JAVAFX ; then
WITH_JAVAFX_STR=-javafx
else
WITH_JAVAFX_STR=
fi
ZIP_NAME="${BUILD_DIR}/jdk8u${BUILD_TARGET_ARCH}${BUILD_MODE}${WITH_JAVAFX_STR}zip"
if $BUILD_JAVAFX ; then
progress "call build_javafx script"
"$SCRIPT_DIR/build-javafx.sh" "$JDK_IMAGE_DIR" "$ZIP_NAME"
else
pushd "$JDK_IMAGE_DIR"
zip -r "$ZIP_NAME" .
popd
fi