环境:
os: MAC OS X 10.10.1 yosemite
target build OPENJDK:jdk8
Xcode:6.1
LLVM Version:
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
步骤:
1 国内hg拉取代码不靠谱,到这里打包下载,118M
http://download.java.net/openjdk/jdk8/
2
安装X11,系统默认好像是没有这个东西,需要下载安装XQuartz,然后link下 sudo ln -s /usr/X11/include/X11 /usr/include/X11
3
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
4 安装Xcode的Command line tools、freetype
5 ./configure --enable-debug --with-target-bits=64
6 cd jdk8;
unset JAVA_HOME
unset CLASSPATH
make CC=clang COMPILER_WARNINGS_FATAL=false LFLAGS='-Xlinker -lstdc++' USE_CLANG=true LP64=1 LANG=C ALT_BOOTDIR=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home ARCH_DATA_MODEL=64 HOTSPOT_BUILD_JOBS=8 ALT_FREETYPE_HEADERS_PATH=/Users/mungo/Downloads/work/homebrew-master/Cellar/freetype/2.5.5/include ALT_FREETYPE_LIB_PATH=/Users/mungo/Downloads/work/homebrew-master/Cellar/freetype/2.5.5/lib
7 验证结果:
./build/macosx-x86_64-normal-server-fastdebug/jdk/bin/java -version
openjdk version "1.8.0-internal-fastdebug"
OpenJDK Runtime Environment (build 1.8.0-internal-fastdebug-mungo_2015_01_29_16_11-b00)
OpenJDK 64-Bit Server VM (build 25.0-b70-fastdebug, mixed mode)
出现的问题:
1 clang: error: unknown argument: '-fcheck-new' [-Wunused-command-line-argument-hard-error-in-future] 于是直接打开YourOpenJDK/hotspot/make/bsd/makefiles/gcc.make,把这行(line 193)给注释掉
2 relocInfo.hpp错误。 将接口的默认值去掉,把默认值放到的方法参数里即可。hotspot/src/share/vm/code/relocInfo.hpp
+ inline friend relocInfo prefix_relocInfo(int datalen);
+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);
}
参考文章:
1 http://hllvm.group.iteye.com/group/topic/39814
2 http://yueyemaitian.iteye.com/blog/2038304
另:openjdk 7 hotspot我可以编译成功,但是最后打包的时候,出现 执行cp 错误.没找到原因