brew install mercurial
1 | hg clone http://hg.openjdk.java.net/jdk8/jdk8 java-source |
brew install freetype
1 | inline friend relocInfo prefix_relocInfo(int datalen=0); |
1 | inline friend relocInfo prefix_relocInfo(int datalen); |
configure: error: GCC compiler is required
错误1 | as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5 |
修改后为:
1 | #as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5 |
本机的xcode为7.3.1,编译器为clang,版本为Apple LLVM version 7.3.0 (clang-703.0.31);而jdk编译默认需要gcc编译器,由于clang703已经支持大部分的gcc语法,因此此处是直接注释掉编译器检查,当然也可以安装gcc编译器进行编译;
注意:编译器的版本很重要,否则会报一大堆语法错误;如果采用gcc,要求>=3.81
_igvn.type(rng)->is_int() >= 0
改成 _igvn.type(rng)->is_int()->_lo >= 0
否则会出现以下错误:
1 | /Volumes/Working/java-source/hotspot/src/share/vm/opto/loopPredicate.cpp:775:73: error: ordered comparison between pointer and zero ('const TypeInt *' and 'int') |
base() > 0
改成 base() != 0
否则会出现以下错误:
1 | /Volumes/Working/java-source/hotspot/src/share/vm/runtime/virtualspace.cpp:331:14: error: ordered comparison between pointer and zero ('char *' and 'int') |
1 | chmod a+x configure |
1 | ./configure --with-debug-level=slowdebug --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home --with-freetype-include=/usr/local/Cellar/freetype/2.9.1/include/freetype2 --with-freetype-lib=/usr/local/Cellar/freetype/2.9.1/lib --with-target-bits=64 --with-jvm-variants=server --with-jdk-variant=normal --with-milestone=internal --with-num-cores=2 --with-jobs=4 CC=clang CXX=clang++ |
注意:上面带版本号的地方(本机JDK路径,freetype路径)根据实际情况替换
若正常,会出现以下输出:
1 | make COMPILER_WARNINGS_FATAL=false LFLAGS='-Xlinker -lstdc++' CC=clang USE_CLANG=true LP64=1 |
最后我们看到了这样的输出
1 | ----- Build times ------- |
1 | $ cd build/macosx-x86_64-normal-server-slowdebug/jdk/bin |
https://imkiva.com/2018/02/24/building-openjdk8-on-macos/
https://www.jianshu.com/p/4e01daf8c357
https://juejin.im/post/5a6d7d106fb9a01ca47abd8b
原文:https://www.cnblogs.com/lijianming180/p/12262515.html