尝试间接编译 JDK 8(能够间接略过此局部)

筹备工作

  • 在jdk.java.net上下载了JDK 8源码
  • build.html文档,不同的JDK版本,地位不一样。须要仔细阅读

    • Boot JDK 编译JDK,须要JDK的上一个版本,所以这里须要装置JDK 7 (brew install --cask homebrew/cask-versions/zulu7)

configure

bash configure --with-debug-level=slowdebug --with-jvm-variants=server --enable-dtrace --disable-warnings-as-errors

make

在make中可能会遇到各种依赖装置。

总结

新版的macbook pro 应用了m1芯片,所以老版本的不反对编译。如果是Intel芯片的MAC OS,应该问题不大。

在Linux(mint os)上编译JDK

我抉择的是JDK 12的源码,

  • 装置JDK 11
  • 依据build.html
  • 依据bash configure中提醒,装置短少的文件

这个过程很简略,没有呈现什么问题

在macosx-aarch64上 编译JDK 18

目前来说只有JDK 版本17,18,19是能够在macosx-aarch64上装置的。具体参考Support Build Platforms。因为JDK 17是稳固版本,所以编译JDK 18 GA。

遇到的问题

error: parameter 'SizeOfTag' set but not used

这个问题是在JDK-8283221曾经有人发现了。目前优先级不是很高,有个workaround办法 --disable-warnings-as-error

guarantee(val < (1ULL << nbits)) failed: Field too big for insn

这个问题是在JDK-8280476曾经有人发现了。我看了目前只批改了11,17,19 没有批改18。能够依据commit批改一下src/hotspot/cpu/aarch64/immediate_aarch64.cpp

// src/hotspot/cpu/aarch64/immediate_aarch64.cpp uint64_t replicate(uint64_t bits, int nbits, int count){  // 在函数结尾,增加下main代码   assert(count > 0, "must be");  assert(nbits > 0, "must be");  assert(count * nbits <= 64, "must be");  // Special case nbits == 64 since the shift below with that nbits value  // would result in undefined behavior.  if (nbits == 64) {    return bits;  }  //-----------------------  uint64_t result = 0;  uint64_t mask = ones(nbits);

编译

  1. configure

    bash configure --with-debug-level=slowdebug --with-jvm-variants=server --enable-dtrace --disable-warnings-as-errors
  2. make

如果遇到各种依赖装置,用brew装置即可。

后果

java -vopenjdk 18-internal 2022-03-22OpenJDK Runtime Environment (slowdebug build 18-internal+0-adhoc.chenpei.jdk-jdk-18-ga)OpenJDK 64-Bit Server VM (slowdebug build 18-internal+0-adhoc.chenpei.jdk-jdk-18-ga, mixed mode)

总结

目前对于macosx-aarch64的反对还能够,应该随着当前的版本,在macos应该会比较简单。