jdk编译

macos配置情况:

 

 

 

 

 

jdk编译依赖比当前版本至少小一个版本的jdk版本,作为boot,jdk,boot jdk下载:https://jdk.java.net/17/:

https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_macos-x64_bin.tar.gz

 

 

 

 

/Users/aktiger/Downloads/jdk-jdk-18-30

./configure --with-debug-level=fastdebug  --with-boot-jdk=/Users/aktiger/tools/jdk-17.0.2.jdk/Contents/Home

 ./configure --with-boot-jdk='/Users/aktiger/tools/jdk-17.0.2.jdk/Contents/Home' --with-debug-level=slowdebug --with-target-bits=64 --disable-warnings-as-errors --enable-dtrace --with-jvm-variants=server

如果要启用zero解析器,

./configure --with-boot-jdk='/Users/aktiger/tools/jdk-17.0.2.jdk/Contents/Home' --with-debug-level=slowdebug --with-target-bits=64 --disable-warnings-as-errors --enable-dtrace --with-jvm-variants=server --with-jvm-features=zero --with-jvm-variants=zero 

否则bytpecodeinterpreter.cpp在clion中会飘红,因为编译生成的.o文件中都没有bytecodeinterpreter.o

 

 

 

 

 

 

 

 

configure完成后,在代码目录执行 make CONF=macosx-x86_64-server-slowdebug compile-commands

 


 

 编译带zero解析器的jvm,用如下命令:make CONF=macosx-x86_64-zero-slowdebug compile-commands

 

添加了zero选项后,就可以看到bytecodeInterpreter.o的目标文件

 

使用clion,选择compile_commands.json,然后选择open as project:

  

 

 修改源代码的路径,为jdk下载的根目录:/Users/aktiger/Downloads/jdk-jdk-18-30

 

 打开后,头文件不在飘红了:

 

 

 

 

 

 

执行完后,目录结果如下:

 

 编译好的java如下:

 

clion调试:

 

 

 

 

 

 

 

参考:

1. https://blog.csdn.net/whbing1471/article/details/105909135 

2. https://generalthink.github.io/2020/07/22/debug-jvm-12-in-macox/

3. 开启zero解析器:https://segmentfault.com/a/1190000005082098 

4. clion 调试java -version 详细配置 https://www.jianshu.com/p/1121cc4be0a0

 

posted @ 2022-01-26 17:32  justinzhang  阅读(167)  评论(0编辑  收藏  举报