电脑配置:
电脑安装的jdk: jdk1.8.0_151
准备工作:
1、关闭rootless:开机的时候长按command+R,等出来进度条走了,放开,然后进入恢复模式,打开终端,执行 csrutil disable,成功后重启
2、Openjdk8下载:
http://www.java.net/download/openjdk/jdk8/promoted/b132/openjdk-8-src-b132-03_mar_2014.zip
3、XCode :直接从appstroe下载的
4、安装XQuartz
安装好后执行 ln -s /opt/X11/include/X11 /usr/local/include/X11
5、安装freetype
brew install freetype
安装ccache提高编译速度
$ brew install ccache
6、link llvm-gcc和llvm-g++(不确定是否必须,保险起见加上):
sudo ln -s /usr/bin/llvm-g++ /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-g++
sudo ln -s /usr/bin/llvm-gcc /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc
7、修改源码:
# 1. 修改generated-configure.sh(路径:common/autoconf/generated-configure.sh)
注释20061行
// as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5
注释21640行
// as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5
# 2. 修改relocInfo.hpp(路径:hotspot/src/share/vm/code/relocInfo.hpp)
修改367行
inline friend relocInfo prefix_relocInfo(int datalen);
修改472行
inline relocInfo prefix_relocInfo(int datalen = 0) {
assert(relocInfo::fits_into_immediate(datalen), "datalen in limits");
return relocInfo(relocInfo::data_prefix_tag, relocInfo::RAW_BITS, relocInfo::datalen_tag | datalen);
}
# 3. 修改openjdk/hotspot/src/share/vm/opto/loopPredicate.cpp
修改775行为
assert(rng->Opcode() == Op_LoadRange || _igvn.type(rng)->is_int()->_lo >= 0, "must be");
# 4.修改openjdk/hotspot/src/share/vm/runtime/virtualspace.cpp
修改331行为
if (base() != 0) {
开始编译:
1、改文件夹权限
为了防止中间有权限问题,我直接给整个openjdk的文件夹受了777权限
chmod -R 777 openjdk
2、执行configure
sh configure --with-debug-level=slowdebug --with-target-bits=64 --with-jvm-variants=server --with-jdk-variant=normal --with-milestone=internal --with-update-version=b25 --with-build-number=b25 --with-num-cores=2 --with-jobs=2 CC=clang CXX=clang++ --with-freetype-include=/usr/local/include/freetype2 --with-freetype-lib=/usr/local/lib/ --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home --enable-ccache
3、执行make
make COMPILER_WARNINGS_FATAL=false LFLAGS='-Xlinker -lstdc++' CC=clang USE_CLANG=true LP64=1
4、成功
最后
前面写的准备工作基本上把我中间遇到的问题都包括了,那些要修改的源码就是问题的解决。