Mac系统安装
1 | 利用brew search查找mercurial |
Linux系统安装
1 | sudo apt install mercurial |
安装openjdk8
添加代理
一般在下载代码的时候都会很慢,故先配置好代理。我这里是V2Ray。
1 | vim /usr/local/etc/mercurial/hgrc |
下载jdk8u的代码
1 | hg clone https://hg.openjdk.java.net/jdk8u/jdk8u openjdk8 |
漫长的等待,终于等到你
1 | # Finished docs (build time 00:01:52) |
如何在CLion里面做调试,后面我再详细的写一篇。敬请期待~
遇到的坑
问题一:Xcode 4 is required to build JDK 8
1 | configure: error: Xcode 4 is required to build JDK 8, the version found was 11.4.1. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select. |
解决方案:
1 | ➜ openjdk8 vim common/autoconf/generated-configure.sh |
问题二:A gcc compiler is required
1 | configure: error: A gcc compiler is required. Try setting --with-tools-dir. |
最后执行sh configure
终于成功:
1 | ==================================================== |
问题三:include path for libstdc++ headers not found
1 | clang: clangerror: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Werror,-Wstdlibcxx-not-found] |
解决方法
原因:这个原因是Xcode升级到10以后就没有包含lstdc++库了。而 hotspot 居然还一直用着这个,于是编译器找不到 libstdc++ 的头文件就罢工了
解决办法:
打开:https://github.com/imkiwa/xcode-missing-libstdc- , clone 到本地,参考 install.sh 将文件链接或者复制到对应位置(慎重直接执行,请一定事先核对路径是否正确)!
问题四:fatal error: ‘iostream’ file not found
1 | /Users/chenyuan/Workspaces/Openjdk/openjdk8/hotspot/src/share/vm/adlc/archDesc.cpp:#include <iostream>/Users/chenyuan/Workspaces/Openjdk/openjdk8/hotspot/src/share/vm/adlc/adlc.hpp |
解决方案
1 | xcode-select --install |
问题五:unknown argument: ‘-fpch-deps’
解决方案:
hotspot/make/bsd/makefiles/gcc.make
1 | # Compiler warnings are treated as errors |
这一段也要干掉,否则在后续编译中可能会出现clang: error: unknown argument: '-fpch-deps'
1 | ifeq ($(USE_CLANG),) |
问题六:invalid argument ‘-std=gnu++98’ not allowed with ‘C’
1 | Making signal interposition lib... |
解决方案
1 | if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
参考地址
- https://zhuanlan.zhihu.com/p/50220757
- https://www.jianshu.com/p/d9a1e1072f37
- https://www.cnblogs.com/zhengshuangxi/p/11063938.html
- https://juejin.im/entry/5a6c36af6fb9a01cb64f05b8
- https://www.zhoujunwen.com/2019/building-openjdk-8-on-mac-osx-catalina-10-15
- https://www.cnblogs.com/micrari/p/7018474.html
- https://rqsir.github.io/2019/04/19/openjdk-8-使用Clion调试源码/
如果大家喜欢我的文章,可以关注个人订阅号。欢迎随时留言、交流。如果想加入微信群的话一起讨论的话,请加管理员简栈文化-小助手(lastpass4u),他会拉你们进群。