概述
MAC下 JDK8源码编译
此文记录下自己在mac上编译openjdk8的实际操作过程,以及期间出现的问题和解决方式
实操
编译源码
-
安装 mercurial
brew install hg
或者brew install mercurial
加速编译
brew install ccache
-
下载源码
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u cd jdk8u bash get_source.sh
-
阅读源码根目录下
README-builds.html
文件,按照文档给出的指导进行下面的编译操作 -
下载安装jdk7,jdk7和8是可以共存的
-
执行配置
bash ./configure --enable-ccache --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home --with-debug-level=slowdebug --with-native-debug-symbols=internal
报错configure: error: Failed to determine Xcode version. # 查看xcode版本 xcodebuild -version # 报错 xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance # 由于本地安装了xcode 则直接执行下面的命令 问题解决 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
报错
configure: error: Could not find freetype! ## 安装 brew install freetype
最终输出信息
==================================================== A new configuration has been successfully created in /Users/admin/Workspace/src/jdk8u/build/macosx-x86_64-normal-server-slowdebug using configure arguments '--with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home --with-debug-level=slowdebug --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: 64 Tools 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: clang (clang/LLVM) * C Compiler: Version 12.0.5 (at /usr/bin/clang) * C++ Compiler: Version 12.0.5 (at /usr/bin/clang++) Build performance summary: * Cores to use: 4 * Memory limit: 16384 MB
-
编译
CONF参数可以不指定
make images JOBS=8 CONF=macosx-x86_64-normal-server-slowdebug
-
验证是否成功
./build/macosx-x86_64-normal-server-release/jdk/bin/java -version
/Users/admin/Workspace/src/jdk8u/build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version
debug
gdb
很遗憾mac 环境下没法用会卡住,现在官方还没给出解决方案
gdb --args /Users/admin/Workspace/src/jdk8u/build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version
lldb
由于gdb 没法用 ,lldb是个非常好的替代方案
lldb -- /Users/admin/Workspace/src/jdk8u/build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version
可能会碰到线程中断的问题
* thread #3, stop reason = signal SIGSEGV
frame #0: 0x0000000108cc42b4
->
0x108cc42b4: movl
(%rsi), %eax
0x108cc42b6: leaq
0xf8(%rbp), %rsi
0x108cc42bd: vmovdqu %ymm0, (%rsi)
0x108cc42c1: vmovdqu %ymm7, 0x20(%rsi)
Target 0: (java) stopped.
解决方式
process handle -p true -n true -s true SIGSEGV
c
最终成功
链接
jdk github
openjdk
openjdk8 github
最后
以上就是友好豌豆为你收集整理的MAC下 JDK8源码编译MAC下 JDK8源码编译的全部内容,希望文章能够帮你解决MAC下 JDK8源码编译MAC下 JDK8源码编译所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复