环境
macOS Catalina 10.15.7
Xcode 12.3
autoconf 2.69
make 3.81
freetype 2.10.4
JDK 13
clang 12.0.0
clang++ 12.0.0
编译
wget https://download.java.net/openjdk/jdk14/ri/openjdk-14+36_src.zip
unzip openjdk-14+36_src.zip
cd openjdk
sh ./configure
make all
报错信息处理
- src/hotspot/share/runtime/sharedRuntime.cpp报错
报错信息:
sharedRuntime.cpp:2875:85: error: expression does not compute the number of elements in this array; element type is 'double', not 'relocInfo' [-Werror,-Wsizeof-array-div]
解决方法:
编辑src/hotspot/share/runtime/sharedRuntime.cpp
# 修改前:
double locs_buf[20];
buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
# 修改后:
double locs_buf[20];
buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, (sizeof(locs_buf)) / (sizeof(relocInfo)));
- src/java/openjdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m报错
报错信息:
src/java/openjdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m:134:9: error: converting the result of '?:' with integer constants to a boolean always evaluates to 'true' [-Werror,-Wtautological-constant-compare]
解决方法:
编辑src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m
# 修改前:
if (colorIndex < (useAppleColor) ? sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS : java_awt_SystemColor_NUM_COLORS) {
# 修改后:
if (colorIndex < (useAppleColor ? sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS : java_awt_SystemColor_NUM_COLORS)) {
- JavaVM Framework报错
原因:
Xcode 12.3 已经不再包含JavaVM框架
解决方法:
首先执行sh ./configure,然后修改下列文件
a) 编辑make/test/JtregNativeJdk.gmk
# 修改前:
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := -framework JavaVM \
-framework Cocoa -framework JavaNativeFoundation
# 修改后:
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := -framework Cocoa -framework JavaNativeFoundation
b) 编辑build/macosx-x86_64-server-release/spec.gmk
# 删除所有下列字符串
-F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/JavaVM.framework/Frameworks
c) 编辑./build/macosx-x86_64-server-release/buildjdk-spec.gmk
# 删除所有下列字符串
-F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/JavaVM.framework/Frameworks
重新编译
完成上述操作后重新执行make all
最后在build/macosx-x86_64-server-release/images/jdk可以找到编译好的jdk
参考信息
https://bugs.freebsd.org/bugzilla/attachment.cgi?id=212818&action=edit