MacOS 10.15编译openjdk8u详细过程

三年前编译过一次openjdk8,最近需要调试,发现当时编译时没加调试信息,于是准备重新编译,由于机器信息与三年前完全不同,编译时的异常超出我预期,经过一周折腾终于编译通过,以下上本次编译的详细过程,希望对大家避坑有帮助

环境

1. 机器环境信息



JVM输出系统信息
OS:Bsduname:Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
rlimit: STACK 8192k, CORE 0k, NPROC 2784, NOFILE 10240, AS infinityCPU:total 4 (initial active 4) (2 cores per cpu, 2 threads per core) family 6 model 78 stepping 3, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, rtm, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adxMemory: 4k page, physical 16777216k(369628k free)

2.依赖软件安装

  1. Boot-strap JDK : jdk-7u80-macosx-x64.dmg

  2. XQuartz : XQuartz-2.7.11.dmg

  3. brew 安装以下软件

    brew install freetype
    brew install ant
    brew install ccache
    brew install autoconf
    brew install llvm
    brew install binutils
    
  4. 期间为了解决问题安装过gcc@4.9和gcc@7没有使用到

准备

1. mercurial安装

lizhengdeMacBook-Pro:homebrew-core lizheng$ brew install mercurial

2. 代码下载

直接从源码库克隆源码,然后使用命令下载代码

hg clone http://hg.openjdk.java.net/jdk8u/jdk8u jdk8u
hg pull
vim batchget.sh
chmod +x batchget.sh
./batchget.sh 

如果网速不好可以参考网上另一篇文篇,使用批量脚本(batchget.sh),脚本如下

#!/bin/bashfor i in {1..28}
do
sh ./get_source.sh;
done

3. 查看configure帮助

lizhengdeMacBook-Pro:openjdk8 lizheng$ bash configure --help
Running generated-configure.sh

4.安装配置

./configure --with-xcode-path --with-debug-level=slowdebug --with-boot-jdk=`/usr/libexec/java_home -v 1.7`   --enable-debug-symbols --disable-zip-debug-info --with-memory-size=6144 ZIP_DEBUGINFO_FILES=0  OBJCOPY=gobjcopy  --with-jobs=8 CC=clang CXX=clang++  --with-native-debug-symbols=internalconfigure有不少的参数, 具体的参数可以通过 'bash ./configure --help' 查看--with-debug-level=slowdebug   表示构建debug版本, openjdk8去掉了jvmg版本的构建--enable-debug-symbols 和   ZIP_DEBUGINFO_FILES=0  主要是方便调试

运行输出:

lizhengdeMacBook-Pro:jdk8uuu lizheng$ ./configure --with-xcode-path --with-debug-level=slowdebug --with-boot-jdk=`/usr/libexec/java_home -v 1.7`   --enable-debug-symbols --disable-zip-debug-info --with-memory-size=6144 ZIP_DEBUGINFO_FILES=0  OBJCOPY=gobjcopy  --with-jobs=8 CC=clang CXX=clang++  --with-native-debug-symbols=internal
Configure source code has been updated, checking time stamps
Running generated-configure.sh
configure: Configuration created at Mon Apr 20 09:28:00 CST 2020.
configure: configure script generated at timestamp 1585090987.====================================================
A new configuration has been successfully created in
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/build/macosx-x86_64-normal-server-slowdebug
using configure arguments '--with-xcode-path --with-debug-level=slowdebug --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home --enable-debug-symbols --disable-zip-debug-info --with-memory-size=6144 ZIP_DEBUGINFO_FILES=0 OBJCOPY=gobjcopy --with-jobs=8 CC=clang CXX=clang++ --with-native-debug-symbols=internal'.Configuration summary:
* Debug level:    slowdebug
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64Tools summary:
* Boot JDK:       java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)  (at /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home)
* Toolchain:      gcc (GNU Compiler Collection)
* C Compiler:     Version clang version 10.0.0 Target: x86_64-apple-darwin19.4.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin (at /usr/local/opt/llvm/bin/clang)
* C++ Compiler:   Version clang version 10.0.0 Target: x86_64-apple-darwin19.4.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin (at /usr/local/opt/llvm/bin/clang++)Build performance summary:
* Cores to use:   8
* Memory limit:   6144 MB
lizhengdeMacBook-Pro:tmp lizheng$ git clone https://github.com/imkiwa/xcode-missing-libstdc-.git
Cloning into 'xcode-missing-libstdc-'...
remote: Enumerating objects: 597, done.
remote: Counting objects: 100% (597/597), done.
remote: Compressing objects: 100% (232/232), done.
remote: Total 597 (delta 362), reused 597 (delta 362), pack-reused 0
Receiving objects: 100% (597/597), 876.56 KiB | 56.00 KiB/s, done.
Resolving deltas: 100% (362/362), done.lizhengdeMacBook-Pro:tmp lizheng$ sudo mkdir -p Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++
lizhengdeMacBook-Pro:tmp lizheng$ sudo cp -R xcode-missing-libstdc-/include/c++/* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++
lizhengdeMacBook-Pro:tmp lizheng$ sudo cp xcode-missing-libstdc-/lib/*  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/

5.构建

lizhengdeMacBook-Pro:jdk8uuu lizheng$ make all JOBS=8 ZIP_DEBUGINFO_FILES=0 COMPILER_WARNINGS_FATAL=false  CC=clang USE_CLANG=true LP64=1

构建输出:

Building OpenJDK for target 'all' in configuration 'macosx-x86_64-normal-server-slowdebug'## Starting langtools
Compiling 2 files for BUILD_TOOLS
Compiling 32 properties into resource bundles
Compiling 782 files for BUILD_BOOTSTRAP_LANGTOOLS
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Creating langtools/dist/bootstrap/lib/javac.jar
Updating langtools/dist/lib/src.zip
Compiling 785 files for BUILD_FULL_JAVAC
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Creating langtools/dist/lib/classes.jar
## Finished langtools (build time 00:00:40)## Starting hotspot
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlparse.cpp
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/archDesc.cpp
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/arena.cpp
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/dfa.cpp
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/dict2.cpp
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/arena.cpp:25:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not found
#include <iostream>^~~~~~~~~~
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/filebuff.cpp
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlparse.cpp:27:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not found
#include <iostream>^~~~~~~~~~
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/archDesc.cpp:27:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not found
#include <iostream>^~~~~~~~~~
Compiling /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/forms.cpp
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
clang-10: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/dfa.cpp:26:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not found
#include <iostream>^~~~~~~~~~
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/forms.cpp:26:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not found
#include <iostream>^~~~~~~~~~
1 error generated.
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/filebuff.cpp:26:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not foundmake[6]: *** [../generated/adfiles/arena.o] Error 1
make[6]: *** Waiting for unfinished jobs....#include <iostream>^~~~~~~~~~
In file included from /Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/dict2.cpp:27:
/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/hotspot/src/share/vm/adlc/adlc.hpp:36:10: fatal error: 'iostream' file not found
#include <iostream>^~~~~~~~~~
1 error generated.
make[6]: *** [../generated/adfiles/archDesc.o] Error 1
1 error generated.
make[6]: *** [../generated/adfiles/filebuff.o] Error 1
1 error generated.
make[6]: *** [../generated/adfiles/forms.o] Error 1
1 error generated.
1 error generated.
make[6]: *** [../generated/adfiles/dict2.o] Error 1
make[6]: *** [../generated/adfiles/dfa.o] Error 1
1 error generated.
make[6]: *** [../generated/adfiles/adlparse.o] Error 1
make[5]: *** [ad_stuff] Error 2
make[4]: *** [debug] Error 2
make[3]: *** [generic_build2] Error 2
make[2]: *** [debug] Error 2
make[1]: *** [/Users/lizheng/Documents/3-data/5-source/java/javase/jdk8uuu/build/macosx-x86_64-normal-server-slowdebug/hotspot/_hotspot.timestamp] Error 2
make: *** [hotspot-only] Error 2==============================================================lizhengdeMacBook-Pro:jdk8uuu lizheng$ export CFLAGS="-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1"
lizhengdeMacBook-Pro:jdk8uuu lizheng$ export CXXFLAGS="-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1"
lizhengdeMacBook-Pro:jdk8uuu lizheng$ export LDFLAGS=-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/
lizhengdeMacBook-Pro:jdk8uuu lizheng$ export LIBRARY_PATH=$LIBRARY_PATH:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/==============================================================lizhengdeMacBook-Pro:jdk8uuu lizheng$ make all JOBS=8 ZIP_DEBUGINFO_FILES=0 COMPILER_WARNINGS_FATAL=false  CC=clang USE_CLANG=true LP64=1
Building OpenJDK for target 'all' in configuration 'macosx-x86_64-normal-server-slowdebug'## Starting langtools
## Finished langtools (build time 00:00:00)## Starting hotspot
## Finished docs (build time 00:03:11)----- Build times -------
Start 2020-04-20 09:32:00
End   2020-04-20 09:49:13
00:00:42 corba
00:01:01 demos
00:03:11 docs
00:03:55 hotspot
00:01:50 images
00:00:22 jaxp
00:00:39 jaxws
00:05:11 jdk
00:00:00 langtools
00:00:22 nashorn
00:17:13 TOTAL
-------------------------
Finished building OpenJDK for target 'all'

配置期异常

1.错误Xcode 4 is required to build JDK 8, the version found was 11.4.

configure: error: Xcode 4 is required to build JDK 8, the version found was 11.4. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.

修改配置文件common/autoconf/generated-configure.sh,去除!

26788     if test ! "${XC_VERSION_PARTS[0]}" = "4"; then
26789       as_fn_error $? "Xcode 4 is required to build JDK 8, the version found was $XCODE_VERSION. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.      " "$LINENO" 5
26790     fi

2.错误# as_fn_error $? "A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir." "$LINENO" 5参考文章

修改后为
#as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5

3.错误configure: error: Unable to find objcopy, cannot enable debug-symbols

checking for target address size... 64 bits
checking whether byte ordering is bigendian... no
checking if compiler supports "-m64"... yes
checking if compiler supports "-m64"... yes
checking if we should generate debug symbols... configure: error: Unable to find objcopy, cannot enable debug-symbols
configure exiting with result code 1

安装binutils,并加上OBJCOPY=gobjcopy

参考:https://www.cnblogs.com/jhxxb/p/12558970.html

lizhengdeMacBook-Pro:openjdk8 lizheng$ brew install binutils
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles/binutils-2.34.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring binutils-2.34.catalina.bottle.tar.gz
==> Caveats
binutils is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT provides the same tools.If you need to have binutils first in your PATH run:echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> ~/.bash_profileFor compilers to find binutils you may need to set:export LDFLAGS="-L/usr/local/opt/binutils/lib"export CPPFLAGS="-I/usr/local/opt/binutils/include"==> Summary
												

MacOS 10.15编译openjdk8u详细过程相关推荐

  1. 黑苹果 MacOS 10.15 Catalina 安装详细教程带工具资料

    图文教程悦享地址:点击打开链接 视频教程 B站地址:点击打开链接​ 一.准备工作 一个8G以上的U盘(有的U盘标的是8G,实际只有X,实际容量小于7.5G的会失败) MacOS镜像.TransMac( ...

  2. 最详细AMD Ryzen CPU,VMware 15安装macOS 10.15.x Catalina 记录(第一篇)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 安装介绍 安装方式 成功案例 前期准备 工具准备 VMware Workstation 15. ...

  3. 如何干净的删除vm_如何在macOS 10.15 Catalina绕过XProtect?

    在macOS 10.15 Catalina中,Apple进行了许多安全性能地改进,包括通过使所有可执行文件都受XProtect扫描来加固系统,而不管文件是否带有com.apple.quarantine ...

  4. transmac装黑苹果_黑苹果 篇一:黑苹果安装-clover引导10.15.3超详细

    黑苹果 篇一:黑苹果安装-clover引导10.15.3超详细 2020-09-05 23:06:51 41点赞 245收藏 25评论 本教程面向小白用户,我从初中高中开始接触黑苹果,当时弄了很长时间 ...

  5. Acer 4750 安装黑苹果_黑苹果 MacOS 10.15 Catalina 最新安装教程

    原创教程地址:黑苹果 MacOS 10.15 Catalina安装教程(店铺远程安装收集+定期维护更新) B站视频教程:https://www.bilibili.com/video/av5824875 ...

  6. AMD CPU VMware 16 Pro安装macOS 10.15

    AMD CPU VMware 16 Pro安装macOS 10.15 原文参考https://www.calonye.com/24169.html 安装主要过程截图参考https://www.mac- ...

  7. mac android工具下载,适用于Mac OS的安卓数据恢复软件Android Toolkit,支持macOS 10.15?...

    原标题:适用于Mac OS的安卓数据恢复软件Android Toolkit,支持macOS 10.15? 适用于Mac OS的安卓数据恢复软件你觉得哪款好用? 安卓数据恢复软件Android Tool ...

  8. MacOS 10.15 Laravel框架 使用 Box/Spout 导入导出Excel

    MacOS 10.15 Laravel框架 使用 Box/Spout 导入导出Excel 准备工作 环境条件 安装Composer 使用Composer安装 Box/Spout 导入Excel 官方描 ...

  9. oracle 操作系统升级,学习笔记:Oracle升级 linux操作系统10.2.0.1 升级至 10.2.0.3详细过程...

    天萃荷净 记录一次用户现场Oracle 10G数据库升级的过程,Linux操作环境 FOR 10.2.0.1 to 10.2.0.3的版本升级过程 数据库版本linux 32位(10.2.0.1升级到 ...

  10. macOS 10.11、macOS 10.12、macOS 10.13、macOS 10.14、macOS 10.15 制作可用于虚拟机安装的 CDR/ISO 系统镜像指导教程

    开篇说明:不论是用 UltraISO,或者是用 MacOS 系统中的 磁盘工具 的格式转换功能进行 原版 DMG ==> CDR/ISO 转换出来的 CDR/ISO 文件只是进行了格式(容器)转 ...

最新文章

  1. codevs——1019 集合论与图论
  2. C#/.NET基于Topshelf创建Windows服务的守护程序作为服务启动的客户端桌面程序不显示UI界面的问题分析和解决方案
  3. 的训练过程_【能力模式】能力培养是一个训练过程,掌握三个要点,一个诀窍...
  4. ubuntu基于apache+postgresql编译安装zabbix
  5. [BUUCTF-pwn]——axb_2019_fmt32
  6. 给新手程序猿的16个必备小妙招
  7. 19、java中枚举
  8. PHP判断字符串是纯英文、纯汉字或汉英混合
  9. 基于Android平台淘宝网手机客户端实战开发(共四季,涉及各类技术应用)
  10. [Vue.js] 深入 -- 案例 - 购物车
  11. Win32Asm学习笔记[不断更新]
  12. oracle日期按时间点过滤,Oracle数据库日期过滤方法性能比较
  13. 直播预告:摄影测量影像快速立体匹配关键技术研究
  14. 在cmd中编译C语言方法
  15. Python3.7安装Geenlet
  16. php x12,小辣椒x12pro是什么处理器,一款专门为老年人服务的手机
  17. 【转载声明】关于文章转载到微信公众号
  18. php中UNIX时间戳转换为日期
  19. 浙江大学计算机学院 潘刚,潘刚 - 江苏科技大学 - 生物技术学院
  20. vlookup使用步骤_VLOOKUP函数的使用方法(入门级)

热门文章

  1. 《财经》杂志:盛大新浪梦纪实(完全版)
  2. 电赛专题 |国一作品_线路负载及故障检测装置
  3. php如何替换ico图标,wordpress网站怎么设置更换站点favicon ico图标
  4. Unity 自由视角的惯性旋转
  5. 十大项目管理知识-进度管理
  6. 一个小时学会画网络拓扑图(附标准素材)
  7. Excel绘制CDF图
  8. 慕课秒杀项目seckill
  9. 从小学算术的速算与二进制速算,分析基础与窍门的关系:
  10. Excel 组及分级显示制作教程