在Mac上编译OpenJDK10源码

官方说明 :

  1. Get the complete source code:
    hg clone http://hg.openjdk.java.net/jdk10/master

  2. Run configure:
    bash configure

    If configure fails due to missing dependencies (to either the toolchainexternal libraries or the boot JDK), most of the time it prints a suggestion on how to resolve the situation on your platform. Follow the instructions, and try running bash configure again.

  3. Run make:
    make images

  4. Verify your newly built JDK:
    ./build/*/images/jdk/bin/java -version

  5. Run basic tests:
    make run-test-tier1

如何构建,可以查看里面的文档说明:  OpenJDK10/doc/building.html

============  以下为操作实例 ==============================================

1. 准备安装环境:

首先需要准备一个Xcode

重要: 我用的是Xcode9.4.1 版本 . Xcode10版本不好用, 因为升级后有的包给删了,导致无法编译!!!!!!!!!!!!!!!!!!.

官方下载地址:   https://developer.apple.com/download/more/

网盘下载地址:    https://pan.baidu.com/s/1yp0eqLJtHV0X-ppcxeUewg  密码:nnlt

brew 这个命令我就不说了, 去查一下,怎么安装.

brew install freetype ccache

brew install mercurial

在命令行输入 hg 命令有如下输出:

2.拉取源码包:

hg clone http://hg.openjdk.java.net/jdk10/master openjdk10

注: 这个超级难下载,易炸毛.   真心下载不下来的话,去我 网盘 上下载吧.

链接:https://pan.baidu.com/s/1hPsT2P_nNFLNsjwYRHTItQ  密码:nkb6

在此非常感谢: @Zhao Hunter 

下载完的目录:

3.配置参数

接下来配置编译参数,以下是相关选项说明

  • --with-debug-level=slowdebug 启用slowdebug级别调试
  • --enable-dtrace 启用dtrace
  • --with-jvm-variants=server 编译server类型JVM
  • --with-target-bits=64 指定JVM为64位
  • --enable-ccache 启用ccache,加快编译
  • --with-num-cores=8 编译使用CPU核心数
  • --with-memory-size=8000 编译使用内存
  • --disable-warnings-as-errors 忽略警告  , mac 使用 xcode 编译, 官方要求加上这个参数.
  • --with-freetype  设置freetype的路径, 这个路径必须为你机器上的路径,记得修改 !!!! 

$ bash configure --with-debug-level=slowdebug --enable-dtrace --with-jvm-variants=server --with-target-bits=64 --enable-ccache --with-num-cores=8 --with-memory-size=8000 --disable-warnings-as-errors --with-freetype=/usr/local/Cellar/freetype/2.10.0

编译完输出:

执行编译

$ make images

测试

$ ./build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version


bogon:OpenJDK10 sysadmin$ ./build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version

openjdk version "10-internal"

OpenJDK Runtime Environment (slowdebug build 10-internal+0-adhoc.sysadmin.OpenJDK10)

OpenJDK 64-Bit Server VM (slowdebug build 10-internal+0-adhoc.sysadmin.OpenJDK10, mixed mode)

参考:

https://hunterzhao.io/post/2018/01/29/compile-openjdk10-source-code-on-mac/

https://github.com/hzio/OpenJDK10

猜你喜欢

转载自blog.csdn.net/zhanglong_4444/article/details/89207433