Mac OSX 10.10 Yosemite编译OpenJDK 9
在Mac OSX 10.10系统上编译了下OpenJDK9,以下仅是个人安装记录,供参考。
编译时间:2015-06-13
系统版本:Mac OS X Yosemite 10.10.4
编译OpenJDK版本:JDK 9
相关软件版本:
XCode版本:XCode6-Beat4 Version 6.0 (6A267n)
JDK版本:1.8.0_45
软件管理工具:brew
Xquartz(X11):2.7.7
参考资料:
编译前期准备:
大致了解官网系统要求:
https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms
源码下载工具安装(此处采用Mercurial工具[OpenJDK的版本管控工具]从官网下载):
安装参考资料:
http://openjdk.java.net/guide/repositories.html
https://mercurial.selenic.com/wiki/Download#Mac_OS_X
本机安装脚本:
安装:
$ brew install mercurial
若link失败,则:
$ sudo brew link mercurial
验证版本不低于2.6.3:hg version
安装后版本3.0.2,改为官网下载安装3.4.1了
安装ccache提高编译速度
$ brew search ccache $ brew install ccache
安装freetype(编译时需要):
brew install freetype
安装失败,提示依赖的libpng无法下载。手工安装:
下载libpng最新版1.6.17(http://sourceforge.net/projects/libpng/files/)并解压:
$ pwd $ cd ./libpng-1.6.17 $ ./configure --prefix=/usr/local/libpng-1.6.17 $ make $ make install $ cd /usr/local/ $ ln -s libpng-1.6.17 /usr/local/libpng $ brew install freetype
获取JDK源码:
$ mkdir OpenJDK9;cd OpenJDK9 $ hg clone $ cd dev $ chmod u+x get_source.sh $ ./get_source.sh
编译配置:
$ bash ./configure --help=short $ bash ./configure --enable-debug --with-target-bits=64 ... ==================================================== A new configuration has been successfully created in OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug using configure arguments ‘--enable-debug --with-target-bits=64‘. Configuration summary: * Debug level: fastdebug * HS debug level: fastdebug * JDK variant: normal * JVM variants: server * OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64 Tools summary: * Boot JDK: java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) (at /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home) * Toolchain: clang (clang/LLVM) * C Compiler: Version Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix (at /usr/bin/clang) * C++ Compiler: Version Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix (at /usr/bin/clang++) Build performance summary: * Cores to use: 2 * Memory limit: 4096 MB
编译:
$ make ... OpenJDK9/jdk9/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m:387:29: error: sending ‘id<NSApplicationDelegate>‘ to parameter of incompatible type ‘id<NSFileManagerDelegate>‘ [-Werror] [NSApp setDelegate: applicationDelegate]; ^~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSFileManager.h:109:47: note: passing argument to parameter ‘delegate‘ here @property (assign) id <NSFileManagerDelegate> delegate NS_AVAILABLE(10_5, 2_0); ^ 1 error generated. make[3]: *** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java.desktop/libosxapp/NSApplicationAWT.o] Error 1 make[2]: *** [java.desktop-libs] Error 2 make[2]: *** Waiting for unfinished jobs....
解决办法如下或者替换XCode版本为6.3.2或者5.几的:
//OpenJDK9/jdk9/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m //387行改成: if (NSApp != nil) { //[NSApp setDelegate: applicationDelegate]; [(NSApplication*)NSApp setDelegate: applicationDelegate]; if (applicationDelegate && qad) { [qad processQueuedEventsWithTargetDelegate: applicationDelegate]; qad = nil; } }
重新编译:
$ make clean $ make ... OpenJDK9/jdk9/jdk/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c:855:33: error: comparison of array ‘rasterP->sppsm.offsets‘ not equal to a null pointer is always true [-Werror,-Wtautological-pointer-compare] else if (rasterP->sppsm.offsets != NULL) { ~~~~~~~~~~~~~~~^~~~~~~ ~~~~ 1 error generated. make[3]: *** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java.desktop/libawt/awt_parseImage.o] Error 1 make[2]: *** [java.desktop-libs] Error 2 make[2]: *** Waiting for unfinished jobs.... ERROR: Build failed for target ‘default‘ in configuration ‘macosx-x86_64-normal-server-fastdebug‘ (exit code 2) Hint: If caused by a warning, try configure --disable-warnings-as-errors make[1]: *** [main] Error 2 make: *** [default] Error 2
解决办法:
//OpenJDK9/jdk9/jdk/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c //855行改成如下的(注释掉IF条件): else /** if (rasterP->sppsm.offsets != NULL) **/ {
再重新编译:
$ make clean $ make ... 1 error generated. make[3]: *** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java.desktop/libsplashscreen/splashscreen_sys.o] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [java.desktop-libs] Error 2 ERROR: Build failed for target ‘default‘ in configuration ‘macosx-x86_64-normal-server-fastdebug‘ (exit code 2) Hint: If caused by a warning, try configure --disable-warnings-as-errors make[1]: *** [main] Error 2 make: *** [default] Error 2
解决办法:
//OpenJDK/openJDK9/jdk9/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m //注释掉278行: //[image setScalesWhenResized:YES];
再编,没出现错误了:
$ make clean $ make ... Finished building target ‘default‘ in configuration ‘macosx-x86_64-normal-server-fastdebug‘
编译结果初步验证:
$ cd ./build/* $ ls Makefile configure-support jdk bootcycle-spec.gmk configure.log make-support build.log configure.log.old spec.gmk build.log.old hotspot support buildtools hotspot-spec.gmk compare.sh images $ cd jdk/bin $ ./java -versionopen openjdk version "1.9.0-internal-fastdebug" OpenJDK Runtime Environment (build 1.9.0-internal-fastdebug-stxpons_2015_06_13_16_14-b00) OpenJDK 64-Bit Server VM (build 1.9.0-internal-fastdebug-stxpons_2015_06_13_16_14-b00, mixed mode)
参考JDK源码目录下README-builds.html文件里的Testing章节:
哎呀妈啊,都折腾半天了,还来啊,要先安装jtreg,懒得折腾了。。。下回有空再按官方方法验证。。。
$ cd test $ make PRODUCT_HOME=`pwd`/../build/*/images/j2sdk-image all /Applications/Xcode.app/Contents/Developer/usr/bin/make -k -C ../jdk/test TEST=jdk_all jdk_all echo "Running tests: jdk_all" Running tests: jdk_all for each in jdk_all; do /Applications/Xcode.app/Contents/Developer/usr/bin/make -j 1 TEST_SELECTION=":$each" UNIQUE_DIR=$each jtreg_tests; done make[2]: *** No rule to make target `OpenJDK9/jdk9/test/../build/macosx-x86_64-normal-server-fastdebug/images/j2sdk-image‘, needed by `jtreg_tests‘. make[2]: *** No rule to make target `/java/re/jtreg/4.1/promoted/latest/binaries/jtreg‘, needed by `/java/re/jtreg/4.1/promoted/latest/binaries/jtreg/bin/jtreg‘. make[2]: Target `jtreg_tests‘ not remade because of errors. make[1]: *** [jdk_all] Error 2 make: *** [jdk_all] Error 2
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。