跳至主要內容

构建JDK

zzz大约 17 分钟

构建JDK

先对Github中的文档做一些翻译 2021/11/26

源码下载

Githubopen in new window

硬件环境要求

JDK是一个庞大的项目,编译的过程需要很长的时间,所以需要一台性能不错的机器。

强烈建议在构建中使用 SSD 磁盘,因为磁盘速度是构建性能的限制因素之一我们强烈建议在构建中使用 SSD 磁盘,因为磁盘速度是构建性能的限制因素之一。

操作系统要求

JDK主线项目支持Linux、macOS、AIX和Windows。对于其他系统的支持,在单独的"port"项目中。

macOS

Apple正在使用一种非常激进的方案来推动操作系统更新,并将这些更新与所需的Xcode更新相结合。不幸的是,这使得像JDK这样的项目很难跟上运行macOS的不断更新的计算机的步伐。请参阅‎‎有关Apple Xcode‎open in new window‎的一些策略来处理此问题的部分‎.

标准的macOS环境包含了构建所需的基础工具,但是对于外部库,建议使用包管理器。JDK在示例中使用homebrewopen in new window,但是你可以自行选择你想要用的管理器(或没有)。

Native编译器(工具链)要求

JDK存在大量的需要编译之后才能在目标平台上运行的native代码。理论上,工具链和操作系统应该是独立因素,但是从实践上来看在目标操作系统和工具链之间或多或少。

操作系统工具链版本

Linux gcc 10.2.0 macOS Apple Xcode 10.1 (using clang 10.0.0) Windows Microsoft Visual Studio 2019 update 16.7.2

所有编译器都应该能够编译为C99语言标准,因为源代码中使用了一些C99功能。Microsoft Visual Studio不完全支持C99,因此在实践中,共享代码仅限于使用它支持的C99功能。

gcc

最少需要5.0版本。更老的版本会在configure时产生警告无法工作。

目前的JDK至少需要gcc版本是10.2。

通常来说,两者之间的任何版本都可以使用。

clang

最少需要3.5版本。configure无法接受更老的版本。

在Linux要使用clang去替换gcc,使用--with-toolchain-type=clang

Apple Xcode

最少需要Xcode8,安装方式:

xcode-select --install

建议在更新Xcode时保留旧版本的Xcode以构建JDK。 blog pageopen in new window提供了管理多版本Xcode的一些好的建议。

运行configure前使用xcode-select -s或者使用--with-toolchain-path去指定使用的Xcode版本。例如:configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin

如果最近更新了OS 或者/和 Xcode版本, JDK无法被编译, 请查看 Problems with the Build Environmentopen in new window, 和 Getting Helpopen in new window 寻找一些解决办法。

Microsoft Visual Studio

IBM XL C/C++

‎引导 JDK 要求‎

矛盾的是,构建JDK需要一个预先存在的JDK。这成为“引导JDK”。但是引导JDK不必是直接从OpenJDK社区中提供的源代码构建的JDK。如果要将JDK移植到新平台,则很可能已经存在存在另一个可用于引导JDK到用于改平台的JDK。

经验法则是,用于构建JDK主要版本‎‎N‎‎的引导JDK应该是主要版本‎‎N-1‎‎的JDK,因此对于构建JDK 9,JDK 8适合作为引导JDK。但是,JDK 应该能够"构建自身",因此当前 JDK 源代码的最新构建是一种可接受的替代方案。如果您遵循‎‎N-1‎‎规则,请确保您拥有最新的更新版本,因为 JDK 8 GA 可能无法在所有平台上构建 JDK 9。‎

‎在发布周期的早期,版本‎‎N-1‎‎可能尚未发布。在这种情况下,首选的引导 JDK 将是版本‎‎N-2,‎‎直到版本‎‎N-1‎‎可用。

如果没有自动的检测到引导JDK,或者选中了错误的JDK,可以使用--with-boot-jdk去指定要使用的JDK。

外部库要求‎

‎不同的平台需要不同的外部库。通常,库不是可选的 - 也就是说,它们是必需的或不使用的。‎

如果所需的库没有被configure检测到,你需要提供他们的路径。configure有两种参数的方式去指定外部库:--with-<LIB>=<path>或者--with-<LIB>-include=<path to include> --with-<LIB>-lib=<path to lib>。第一种方式更近简单,但要求包含文件和库文件驻留在此目录下的默认层次结构中。作为备选,第二种方式允许分别指定包含目录和库目录。

FreeType

在任何平台上都不需要来自 FreeType Project 的 FreeType2。在基于 unix 的平台上,如果配置构建构件将引用系统安装的库,而不是绑定 JDK 自己的副本,则会出现异常。

  • macOS,运行brew install freetype

  • 基于apt的Linux,运行sudo apt-get install libfreetype6-dev

  • 基于rpm的Linux,运行sudo yum install freetype-devel

  • Alpine Linux,运行sudo apk add freetype-dev

如果configure没有自动检测到FreeType,可以通过--with-freetype-include=<path>--with-freetype-lib=<path>来指定。

CUPS

所有平台都需要通用 UNIX 打印系统头文件,Windows 除外。通常这些文件是由操作系统提供的。

  • 要在基于 apt 的 Linux 上安装,请尝试运行 sudo apt-get install libcups2-dev
  • 要在基于 rpm 的 Linux 上安装,请尝试运行 sudo yum install cups-devel
  • 要在 Alpine Linux 上安装,请尝试运行sudo apk add cups-dev

如果 configure 没有正确定位 CUPS 文件,则使用 --with-CUPS=<path>

X11

Linux 上需要某些 x11库和包含文件。

  • 要在基于 apt 的 Linux 上安装,试着运行 sudo apt-get install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev。

  • 要在基于 rpm 的 Linux 上安装,请尝试运行 sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel。

  • 要在 Alpine Linux 上安装,请尝试运行 sudo apk add libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev。

如果 configure 没有正确定位 x11文件,则使用 --with-x=<path>

ALSA

在 Linux 上需要高级 Linux 声音架构,至少需要 ALSA 的0.9.1版本。

  • 要在基于 apt 的 Linux 上安装,请尝试运行 sudo apt-get install libasound2-dev。
  • 要在基于 rpm 的 Linux 上安装,请尝试运行 sudo yum install alsa-lib-devel。
  • 要在 Alpine Linux 上安装,请尝试运行 sudo apk add alsa-lib-dev。

如果 configure 没有正确定位 ALSA 文件,则使用 -- with-ALSA = < path > 。

libffi Liffi

在构建 Hotspot 的零版本时,需要使用可移植外部函数接口库 libffi。

  • 要在基于 apt 的 Linux 上安装,请尝试运行 sudo apt-get install libffi-dev。
  • 要在基于 rpm 的 Linux 上安装,请尝试运行 sudo yum install libffi-devel。
  • 要在 Alpine Linux 上安装,请尝试运行 sudo apk add libffi-dev。

如果 configure 没有正确定位 libffi 文件,则使用 -- with-libffi = < path > 。

构建工具需求

Autoconf 自动配置文件夹

JDK 在所有平台上都需要 Autoconf,至少需要2.69版本。

  • 要在基于 apt 的 Linux 上安装,请尝试运行 sudo apt-get install autoconf。
  • 要在基于 rpm 的 Linux 上安装,请尝试运行 sudo yum install autoconf。
  • 要在 Alpine Linux 上安装,请尝试运行 sudo apk add autoconf。
  • 要在 macOS 上安装,请尝试运行 brew install autoconf
  • To install on Windows, try running <path to Cygwin setup>/setup-x86_64 -q -P autoconf.
  • 要在 Windows 上安装,请尝试运行 cygwin setup/setup-x86 _ 64-q-p autoconf 的 < path。

如果 configure 在定位你的 AUTOCONF 安装时遇到了问题,你可以使用 AUTOCONF 环境变量指定它,像这样:

AUTOCONF=<path to autoconf> configure ...

GNU Make

JDK 需要 gnumake,不支持其他 Make 风格。

必须使用 GNU Make 的至少版本3.81。对于支持 GNU Make 4.0或更高版本的发行版,我们强烈推荐它。GNU Make 4.0包含了处理并行构建(由 -- with-output-sync 支持)以及速度和稳定性改进的有用功能。

请注意,configure 将定位并验证 make 的正常运行版本,并将该 make 二进制文件的路径存储在配置中。如果在命令行上使用 make 启动构建,您将使用 PATH 中的第一个 make 版本,而不必使用存储在配置中的版本。这个初始 make 将被用作“ bootstrap make”,在第二个阶段,configure 定位的 make 将被调用。通常情况下,这不会带来任何问题,但是如果您的路径中有一个非常老的 Make,或者一个非 gnu Make,这可能会导致问题。

如果您想覆盖 configure 找到的默认 MAKE,请使用 MAKE configure 变量,例如 configure MAKE =/opt/gnu/MAKE。

GNU Bash

JDK 需要 gnubash,不支持其他 shell。

必须至少使用 GNU Bash 的3.2版本。

Running Configure 运行配置

要构建 JDK,您需要一个“配置”,它包含存储构建输出的目录,以及关于平台、特定构建机器和影响构建方式的选择的信息。

这个配置是由配置脚本创建的,配置脚本的基本调用如下:

bash configure [options]

这将创建包含配置的输出目录,并为生成结果设置一个区域。这个目录通常看起来像 build/linux-x64-server-release,但实际名称取决于特定的配置。(也可以直接设置,请参阅使用多种配置)。这个目录在这个文档中被称为 $BUILD。

configure 将尝试找出您正在运行的系统以及所有必要的构建组件都在哪里。如果您已经安装了构建的所有先决条件,那么它应该可以找到所有的内容。如果它不能自动检测到任何组件,它将退出并通知您有关问题。

一些命令行示例:

  • 使用 c:\freetype-i586中的 Freetype2为 Windows 创建一个32位版本:

    bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32
    
  • 在启用服务器 JVM 和 DTrace 的情况下创建调试版本:

    bash configure --enable-debug --with-jvm-variants=server --enable-dtrace
    

Common Configure Arguments 常见的配置参数

下面是一些最常见和最重要的配置参数。

要获得所有可用配置参数的最新信息,请运行:

bash configure --help

(注意,这个帮助文本还包括常规的 autoconf 选项,比如 -- dvidir,它与 JDK 无关。要只列出特定于 jdk 的特性,可以使用 bashconfigure -- help = short。)

配置裁剪生成的参数

  • -- enable-debug -- 将调试级别设置为 fastdebug (这是 -- with-debug-level = fastdebug 的缩写)
  • -- with-debug-level = < level >-设置调试级别,可以是发布、快速调试、缓慢调试或优化。默认是释放。优化的版本带有附加的 Hotspot 调试代码。
  • -- with-native-debug-symbols = < method >-指定是否以及如何生成本机调试符号。可用的方法有无、内部、外部、压缩。默认行为取决于平台。有关详细信息,请参阅本机调试符号。
  • -- with-version-string = < string >-指定此构建将被标识为的版本字符串。
  • -- with-version-< part > = < value >-a group of options,其中 < part > 可以是 pre,opt,build,major,minor,security 或 patch 的任意选项。使用这些选项仅从默认值修改版本字符串的相应部分,或者修改 -- with-version-string 提供的值。
  • -- with-jvm-variant = < variant > [ ,< variant > ... ]-构建 Hotspot 的指定变体(或变体)。有效的变体有: 服务器、客户机、最小、核心、零、自定义。请注意,并非所有变量都可以在单个构建中组合。
  • -- enable-JVM-feature-< feature > 或 -- disable-JVM-feature-< feature->-Include (or exclude) < feature > 作为 Hotspot 中的 JVM 特性。还可以指定要启用的特性列表,用空格或逗号分隔,如 -- with-jvm-features = < feature > [ ,< feature > ... ]。如果你用-作为前缀 < feature > ,它将被禁用。这些选项将修改您正在构建的 JVM 变体的默认特性列表。对于自定义 JVM 变体,默认列表为空。可以使用 bashconfigure -- help 找到有效的 JVM 特性的完整列表。
  • -- with-target-bits = < bits >-创建一个适合在 < bits > 平台上运行的目标二进制文件。使用它在64位构建平台上创建32位输出,而不是进行完整的交叉编译。(这就是所谓的简化版本。)

在 Linux、 BSD 和 AIX 上,可以覆盖 Java 默认搜索运行时/JNI 库的地方。在为系统 JNI 库存在一个特殊的共享目录的情况下,这是很有用的。通过设置 java.library.path 属性,可以在运行时重写此设置。

  • -- with-jni-libpath = < path >-在搜索运行库时使用指定的路径作为默认路径。

Configure Arguments for Native Compilation 配置本机编译的参数

  • -- with-devkit = < path >-使用此 devkit 来编译器、工具和资源
  • -- with-sysroot = < path >-使用此目录作为 sysroot
  • -- with-extra-path = < path > [ ; < path > ]-在搜索所有类型的二进制文件时,将这些目录前置到默认路径
  • -- with-toolchain-path = < path > [ ; < path > ]-在搜索工具链二进制文件(编译器等)时预置这些目录
  • -- with-extra-cflags = < flags >-在编译 JDK c 文件时附加这些标志
  • -- with-extra-cxxflags = < flags >-在编译 JDK c + + 文件时附加这些标志
  • -- with-extra-ldflags = < flags >-在链接 JDK 库时附加这些标志

Configure Arguments for External Dependencies 为外部依赖项配置参数

  • --with-boot-jdk=<path> - Set the path to the Boot JDKopen in new window
  • --with-freetype=<path> - Set the path to FreeTypeopen in new window
  • -- with-FreeType = < path >-设置路径为 FreeType
  • -- with-CUPS = < path >-将路径设置为 CUPS
  • -- with-x = < path >-设置路径为 X11
  • --with-alsa=<path> - Set the path to ALSAopen in new window
  • -- with-libffi = < path >-设置路径为 libffi
  • -- with-JTReg = < path >-Set the path to JTReg. 参见运行测试

JDK 存储库中包括 JDK 使用的某些第三方库(libjpeg、 giflib、 libpng、 lcms 和 zlib)。JDK 构建的默认行为是使用包含的(“捆绑”) libjpeg、 giflib、 libpng 和 lcms 版本。对于 zlib,系统 lib (如果存在)除了 Windows 和 AIX 上使用。但是,捆绑的库可能会被外部版本所取代。为此,在这些参数中将 system 指定为 < source > 选项。(缺省值是捆绑的)。

  • --with-libjpeg=<source> - Use the specified source for libjpeg

  • --with-giflib=<source> - Use the specified source for giflib

  • --with-libpng=<source> - Use the specified source for libpng

  • --with-lcms=<source> - Use the specified source for lcms

  • --with-zlib=<source> - Use the specified source for zlib

  • 在 Linux 上,可以选择 c + + 运行时的静态或动态链接。默认是静态链接,如果找不到静态库,则使用动态链接作为回退。

  • --with-stdc + + lib = <method>-使用指定的方法(静态、动态或默认)链接 c + + 运行时。

Configure Control Variables 配置控制变量

It is possible to control certain aspects of configure by overriding the value of configure variables, either on the command line or in the environment.

可以通过在命令行或环境中重写 configure 变量的值来控制配置的某些方面。

Normally, this is not recommended. If used improperly, it can lead to a broken configuration. Unless you're well versed in the build system, this is hard to use properly. Therefore, configure will print a warning if this is detected.

通常情况下,这是不推荐的。如果使用不当,可能导致配置中断。除非你精通构建系统,否则很难正确使用它。因此,如果检测到这一点,configure 将打印一个警告。

However, there are a few configure variables, known as control variables that are supposed to be overridden on the command line. These are variables that describe the location of tools needed by the build, like MAKE or GREP. If any such variable is specified, configure will use that value instead of trying to autodetect the tool. For instance, bash configure MAKE=/opt/gnumake4.0/bin/make.

但是,有一些配置变量(称为控制变量)应该在命令行上重写。这些变量描述构建所需的工具的位置,如 MAKE 或 GREP。如果指定了任何此类变量,configure 将使用该值,而不是尝试自动检测工具。例如,bash 配置 MAKE =/opt/gnumake4.0/bin/MAKE。

If a configure argument exists, use that instead, e.g. use --with-jtreg instead of setting JTREGEXE.

如果存在 configure 参数,请使用它,例如使用 -- with-jtreg 而不是设置 JTREGEXE。

Also note that, despite what autoconf claims, setting CFLAGS will not accomplish anything. Instead use --with-extra-cflags (and similar for cxxflags and ldflags).

还要注意,不管 autoconf 声称什么,设置 CFLAGS 将不会完成任何事情。而是使用 -- with-extra-cflags (类似于 cxxflags 和 ldflags)。

本机编译JDK8

MacOS 12.0.1 (21A559)

Xcode Version 13.1 (13A1030d)

每个版本的JDK编译可能会有区别,具体参考对应版本中的文档。

# 环境准备
xcode-select --install
brew install freetype
brew install autoconf

# 编译
bash configure --with-target-bits=64 --with-debug-level=slowdebug  --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home  2>&1 | tee configure_mac_x64.log

bash configure   --with-tools-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr  CC=clang CXX=clang++  --with-target-bits=64 --with-debug-level=slowdebug  --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home  2>&1 | tee configure_mac_x64.log

bash configure --enable-unlimited-crypto  CC=clang CXX=clang++  --with-target-bits=64 --with-debug-level=slowdebug  --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home  2>&1 | tee configure_mac_x64.log

--enable-unlimited-crypto 开启无限制加密策略。这个不加的话,到后面编译成功,执行 java -version 的时候会提示:

# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

bash configure CC=clang CXX=clang++ --with-target-bits=64 --with-debug-level=slowdebug --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home 2>&1 | tee configure_mac_x64.log

configure成功

image-20211126151610558
image-20211126151610558
make all

问题

configure报错

找不到gcc编译器,实际上是安装了的:

configure: error: GCC compiler is required. Try setting --with-tools-dir.
configure exiting with result code 1

打开文件搜索“GCC compiler is required”,注释掉错误打印。

image-20211126150618835
image-20211126150618835

make 报错

clang: error: 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不带lstdc++库,但是hotspot还是需要。

参考quantum6/xcode-missing-libstdcpp (github.com)open in new window 解决

由于本地已经有c++目录,直接执行install会报错,所以将脚本调整一下,让下一层文件夹4.2.1做链接

set -e

sudo ln -s \
    $PWD/include/c++/4.2.1 \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/

sudo ln -s \
    $PWD/lib/libstdc++.6.0.9.tbd \
    $PWD/lib/libstdc++.6.tbd \
    $PWD/lib/libstdc++.tbd \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/

参考:

[1].深夜里安静的编译一个OpenJDK8,坑太多-云海天教程 (yht7.com)open in new window

[2].https://www.cnblogs.com/dwtfukgv/p/14727290.html

本机编译JDK12

源码下载https://download.java.net/openjdk/jdk12/ri/openjdk-12+32_src.zip

环境说明

工具版本
操作系统MacOS 12.0.1 (21A559)
XCodeXcode Version 13.1 (13A1030d)
clangApple clang version 13.0.0 (clang-1300.0.29.3)
clang++Apple clang version 13.0.0 (clang-1300.0.29.3)
bash configure --enable-unlimited-crypto    --with-target-bits=64 --with-debug-level=slowdebug  --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home  2>&1 | tee configure_mac_x64.log

#bash configure --enable-debug --with-jvm-variants=server

错误一

/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/src/hotspot/share/runtime/sharedRuntime.cpp:2873:85: error: expression does not compute the number of elements in this array; element type is 'double', not 'relocInfo' [-Werror,-Wsizeof-array-div]
      buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
                                                                          ~~~~~~~~  ^
/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/src/hotspot/share/runtime/sharedRuntime.cpp:2872:14: note: array 'locs_buf' declared here
      double locs_buf[20];
             ^
/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/src/hotspot/share/runtime/sharedRuntime.cpp:2873:85: note: place parentheses around the 'sizeof(relocInfo)' expression to silence this warning
      buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
                                                                                    ^
1 error generated.

buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
替换为
buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, (sizeof(locs_buf) / sizeof(relocInfo)));


错误二

In file included from /Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/test/hotspot/gtest/logging/logTestFixture.cpp:27:
/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/test/hotspot/gtest/logging/logTestUtils.inline.hpp:34:70: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation]
  "=", "+", " ", "+=", "+=*", "*+", " +", "**", "++", ".", ",", ",," ",+",
                                                                     ^
                                                                    ,
/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/test/hotspot/gtest/logging/logTestUtils.inline.hpp:34:65: note: place parentheses around the string literal to silence warning
  "=", "+", " ", "+=", "+=*", "*+", " +", "**", "++", ".", ",", ",," ",+",
                                                                ^
1 error generated.

补一个逗号

image-20211209102153300
image-20211209102153300

错误三

/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/test/hotspot/gtest/logging/test_logFileOutput.cpp:83:5: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation]
    "filecount=9999999999999999999999999"
    ^
/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/test/hotspot/gtest/logging/test_logFileOutput.cpp:82:5: note: place parentheses around the string literal to silence warning
    "filesize=9999999999999999999999999"
    ^
1 error generated.

补一个逗号

image-20211209102434695
image-20211209102434695

错误四

/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/test/hotspot/gtest/classfile/test_symbolTable.cpp:62:6: error: explicitly assigning value of variable of type 'TempNewSymbol' to itself [-Werror,-Wself-assign-overloaded]
  s1 = s1; // self assignment
  ~~ ^ ~~
1 error generated.

image-20211209103012137
image-20211209103012137

错误五

/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/src/hotspot/share/runtime/arguments.cpp:1452:35: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare]
      if (old_java_vendor_url_bug != DEFAULT_VENDOR_URL_BUG) {
                                  ^  ~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

//      if (old_java_vendor_url_bug != DEFAULT_VENDOR_URL_BUG) { 替换
        if (strcmp(old_java_vendor_url_bug, DEFAULT_VENDOR_URL_BUG) != 0) {

错误六

/Users/zengsl/Project/study/openjdk-compile/openjdk-12+32/src/java.base/unix/native/libjava/ProcessImpl_md.c:362:17: error: 'vfork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations]
    resultPid = vfork();
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/unistd.h:604:1: note: 'vfork' has been explicitly marked deprecated here
__deprecated_msg("Use posix_spawn or fork")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/sys/cdefs.h:208:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
1 error generated.

不知道咋解决。。官方issueopen in new window有人提此问题

本机编译JDK17

openjdk17https://download.java.net/openjdk/jdk17/ri/openjdk-17+35_src.zip

openjdk17下载地址open in new window

bash configure --enable-unlimited-crypto    --with-target-bits=64 --with-debug-level=slowdebug  --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk/Contents/Home  2>&1 | tee configure_mac_x64.log

错误一

error: invalid integral value '16-DMAC_OS_X_VERSION_MIN_REQUIRED=10120' in '-mstack-alignment=16-DMAC_OS_X_VERSION_MIN_REQUIRED=10120'

[JDK-8272700] [macos] Build failure with Xcode 13.0 after JDK-8264848 - Java Bug Systemopen in new window