Hotspot调试环境搭建-基于Ubuntu16.04.7-OpenJDK8u-Clion

  |   0 评论   |   1,375 浏览

环境:
操作系统: Ubuntu16.04.7
OpenJDK版本: jdk8u 关于u是什么意思嗯可以参考:

1 安装版本管理工具.

命令:

sudo apt install mercurial

说明:
mercurial 是OpenJDK的版本管理工具.类似于GIT. 没有深入使用. 基本使用方法与git 可以相通.
比如下载/克隆代码: hg clone http://hg.openjdk.java.net/jdk8u/jdk8u

注意:
进行安装hg时,会报一个错误: Unable to acquire the dpkg frontend lock . 可能的解决文档: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)我是直接重启后解决了些问题.

2 设置代理

类似于git下载国外的仓库会非常的慢.hg的仓库下载也可以使用代理进行.可以提速

在个人home目录~下创建文件:.hgrc内容如下.=>更详细介绍请点击<=

[http_proxy]
host=http://[username]:[password]@[proxy_host]:[port]

友情提示:
如果没有代理.你也可以从其它github的源进行下载. 但是..... github在没有梯子的时候.也是一样的慢.
这似乎是一个死循环. anyway. 先下载代码.

3下载代码

这里的下载代码实际是两部分:
使用上面给的地址下载的是一个壳工程. 类似于一个父工程.
在下载的工程文件里面有一个文件: get_source.sh ,需要再次执行这个脚本才能下载到完整的代码.

cd sourcedir
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u
# 此时已经在sourcedir目录有一个仓库: jdk8u
cd jdk8u
sh ./get_source.sh # 如果没有执行权限可以先执行 chmod u+x get_source.sh

# 执行完成就会得到一个完整的仓库代码.

注:
上面的get_source.sh一定是需要使用 hg clone下载的带版本信息的仓库才能执行. 如果是通过别人说的方法下载的zip包的源码文件,是不能执行的. 切记.

4 预装依赖

安装GCC

sudo apt-get install gcc g++ gdb make

Reading package lists... Done
Building dependency tree
Reading state information... Done
g++ is already the newest version (4:5.3.1-1ubuntu1).
gcc is already the newest version (4:5.3.1-1ubuntu1).
make is already the newest version (4.1-6).
gdb is already the newest version (7.11.1-0ubuntu1~16.5).
0 upgraded, 0 newly installed, 0 to remove and 160 not upgraded.

安装依赖

sudo apt-get install \
libasound2-dev \
libfreetype6-dev \
libcups2-dev \
libfontconfig1-dev \
libxext-dev \
libxrender-dev \
libxtst-dev \
libxt-dev

5 安装BOOT JDK

此步骤略. 可以使用华为的JDK官网镜像下载. 然后使用java开发常用的绿色解压方式使用.
华为JDK镜像服务地址: https://mirrors.huaweicloud.com/java/jdk/

6 编译配置

sh ./configure --with-debug-level=slowdebug \
--disable-zip-debug-info \
--with-target-bits=64 \
--with-boot-jdk=/home/q/java/jdk1.7.0_80 \
--with-freetype-include=/usr/include/freetype2 \
--with-freetype-lib=/usr/lib/x86_64-linux-gnu/

配置结果check

sh ./configure --with-debug-level=slowdebug --disable-zip-debug-info --with-target-bits=64 --with-boot-jdk=/home/q/java/jdk1.7.0_80 --with-freetype-include=/usr/include/freetype2 --with-freetype-lib=/usr/lib/x86_64-linux-gnu/
Running generated-configure.sh
configure: Configuration created at Tue Feb 15 20:53:05 CST 2022.
configure: configure script generated at timestamp 1625670527.
checking for basename... /usr/bin/basename
checking for bash... /bin/bash
checking for cat... /bin/cat
checking for chmod... /bin/chmod
checking for cmp... /usr/bin/cmp
checking for comm... /usr/bin/comm
checking for cp... /bin/cp
checking for cut... /usr/bin/cut
checking for date... /bin/date
checking for gdiff... no
checking for diff... /usr/bin/diff
checking for dirname... /usr/bin/dirname
checking for echo... /bin/echo
checking for expr... /usr/bin/expr
checking for file... /usr/bin/file
checking for find... /usr/bin/find
checking for head... /usr/bin/head
checking for ln... /bin/ln
checking for ls... /bin/ls
checking for mkdir... /bin/mkdir
checking for mktemp... /bin/mktemp
checking for mv... /bin/mv
checking for nawk... /usr/bin/nawk
checking for printf... /usr/bin/printf
checking for rm... /bin/rm
checking for sh... /bin/sh
checking for sort... /usr/bin/sort
checking for tail... /usr/bin/tail
checking for tar... /bin/tar
checking for tee... /usr/bin/tee
checking for touch... /usr/bin/touch
checking for tr... /usr/bin/tr
checking for uname... /bin/uname
checking for uniq... /usr/bin/uniq
checking for wc... /usr/bin/wc
checking for which... /usr/bin/which
checking for xargs... /usr/bin/xargs
checking for gawk... no
checking for mawk... mawk
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for a sed that does not truncate output... /bin/sed
checking for cygpath... no
checking for greadlink... no
checking for readlink... /bin/readlink
checking for df... /bin/df
checking for SetFile... no
checking for cpio... /bin/cpio
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking openjdk-build os-cpu... linux-x86_64
checking openjdk-target os-cpu... linux-x86_64
configure: --with-target-bits are set to build platform address size; argument has no meaning
checking compilation type... native
checking for top-level directory... /home/lijianhong/sourcecode/jdk8u
checking for presence of closed sources... no
checking if closed source is suppressed (openjdk-only)... no
checking which variant of the JDK to build... normal
checking which interpreter of the JVM to build... template
checking which variants of the JVM to build... server
checking which debug level to use... slowdebug
checking for sysroot... 
checking for toolchain path... 
checking for extra path... 
checking where to store configuration... in default location
checking what configuration name to use... linux-x86_64-normal-server-slowdebug
checking for apt-get... apt-get
checking for gmake... no
checking for make... /usr/bin/make
configure: Testing potential make at /usr/bin/make, found using make in PATH
configure: Using GNU make 3.81 (or later) at /usr/bin/make (version: GNU Make 4.1)
checking if find supports -delete... yes
checking for unzip... /usr/bin/unzip
checking for zip... /usr/bin/zip
checking for ldd... /usr/bin/ldd
checking for readelf... /usr/bin/readelf
checking for hg... /usr/bin/hg
checking for stat... /usr/bin/stat
checking for time... /usr/bin/time
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for 7z... no
checking for unzip... unzip
checking for wget... wget
checking headful support... include support for both headful and headless
checking whether to build JFR... true
configure: Found potential Boot JDK using configure arguments
checking for Boot JDK... /home/q/java/jdk1.7.0_80
checking Boot JDK version... 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) 
checking for java in Boot JDK... ok
checking for javac in Boot JDK... ok
checking for javah in Boot JDK... ok
checking for javap in Boot JDK... ok
checking for jar in Boot JDK... ok
checking for rmic in Boot JDK... ok
checking for native2ascii in Boot JDK... ok
checking if Boot JDK is 32 or 64 bits... 64
checking flags for boot jdk java command ...  
checking flags for boot jdk java command for big workloads...  -Xms64M -Xmx1600M -XX:ThreadStackSize=1536 -XX:PermSize=32m -XX:MaxPermSize=160m
checking flags for boot jdk java command for small workloads...  -XX:+UseSerialGC -Xms32M -Xmx512M
configure: Using default toolchain gcc (GNU Compiler Collection)
checking for gcc... /usr/bin/gcc
checking resolved symbolic links for CC... /usr/bin/gcc-5
checking if CC is disguised ccache... no, keeping CC
configure: Using gcc C compiler version 5.4.0 [gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609]
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking for g++... /usr/bin/g++
checking resolved symbolic links for CXX... /usr/bin/g++-5
checking if CXX is disguised ccache... no, keeping CXX
configure: Using gcc C++ compiler version 5.4.0 [g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609]
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/g++ accepts -g... yes
checking how to run the C preprocessor... /usr/bin/gcc -E
checking how to run the C++ preprocessor... /usr/bin/g++ -E
checking for ar... ar
configure: Rewriting AR to "/usr/bin/ar"
checking for strip... strip
configure: Rewriting STRIP to "/usr/bin/strip"
checking for otool... no
checking for nm... nm
configure: Rewriting NM to "/usr/bin/nm"
checking for gobjcopy... no
checking for objcopy... objcopy
configure: Rewriting OBJCOPY to "/usr/bin/objcopy"
checking for gobjdump... no
checking for objdump... objdump
configure: Rewriting OBJDUMP to "/usr/bin/objdump"
checking for broken SuSE 'ld' which only understands anonymous version tags in executables... no
checking for jtreg... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking size of int *... 8
checking for target address size... 64 bits
checking whether byte ordering is bigendian... no
checking if the C++ compiler supports "-std=gnu++98 -Werror"... yes
checking if the C compiler supports "-Wformat-overflow -Werror"... no
checking if the C++ compiler supports "-Wformat-overflow -Werror"... no
checking if both compilers support "-Wformat-overflow -Werror"... no
checking if the C++ compiler supports "-ffp-contract=off -Werror"... yes
checking if the C compiler supports "-m64"... yes
checking if the C++ compiler supports "-m64"... yes
checking if both compilers support "-m64"... yes
checking if the C compiler supports "-m64"... yes
checking if the C++ compiler supports "-m64"... yes
checking if both compilers support "-m64"... yes
checking if we should generate debug symbols... true
checking if we should zip debug-info files... no
checking what type of native debug symbols to use (this will override previous settings)... not specified
configure: --with-native-debug-symbols not specified. Using values from --disable-debug-symbols and --disable-zip-debug-info
checking what is not needed on Linux?... pulse
checking for X... libraries , headers 
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for X11/extensions/shape.h... yes
checking for X11/extensions/Xrender.h... yes
checking for X11/extensions/XTest.h... yes
checking for X11/Intrinsic.h... yes
checking cups/cups.h usability... yes
checking cups/cups.h presence... yes
checking for cups/cups.h... yes
checking cups/ppd.h usability... yes
checking cups/ppd.h presence... yes
checking for cups/ppd.h... yes
configure: Found freetype include files at /usr/include/freetype2 using --with-freetype
checking for freetype includes... /usr/include/freetype2
checking for freetype libraries... /usr/lib/x86_64-linux-gnu
checking if we can compile and link with freetype... yes
checking if we should bundle freetype... yes
checking for ALSA... yes
checking fontconfig/fontconfig.h usability... yes
checking fontconfig/fontconfig.h presence... yes
checking for fontconfig/fontconfig.h... yes
checking for main in -ljpeg... no
configure: Will use jpeg decoder bundled with the OpenJDK source
checking for which giflib to use... bundled
checking for compress in -lz... yes
checking for which zlib to use... bundled
checking for cos in -lm... yes
checking for dlopen in -ldl... yes
checking if dynamic link of stdc++ is possible... yes
checking if static link of stdc++ is possible... yes
checking how to link with libstdc++... static
checking if elliptic curve crypto implementation is present... yes
checking for number of cores... 4
checking for memory size... 7971 MB
checking for appropriate number of jobs to run in parallel... 4
checking whether to use sjavac... no
checking that precompiled headers work... yes
checking is ccache enabled... no
checking if build directory is on local disk... yes
configure: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/config.status
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/spec.gmk
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/hotspot-spec.gmk
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/bootcycle-spec.gmk
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/compare.sh
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/spec.sh
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/Makefile
config.status: creating /home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug/config.h
found it

====================================================
A new configuration has been successfully created in
/home/lijianhong/sourcecode/jdk8u/build/linux-x86_64-normal-server-slowdebug
using configure arguments '--with-debug-level=slowdebug --disable-zip-debug-info --with-target-bits=64 --with-boot-jdk=/home/q/java/jdk1.7.0_80 --with-freetype-include=/usr/include/freetype2 --with-freetype-lib=/usr/lib/x86_64-linux-gnu/'.

Configuration summary:
* Debug level:    slowdebug
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, 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 /home/q/java/jdk1.7.0_80)
* Toolchain:      gcc (GNU Compiler Collection)
* C Compiler:     Version 5.4.0 (at /usr/bin/gcc)
* C++ Compiler:   Version 5.4.0 (at /usr/bin/g++)

Build performance summary:
* Cores to use:   4
* Memory limit:   7971 MB

7 进行编译

这里使用一个bear命令行工具进行编译. 此命令能够生成: compile_commands.json
这个文件可以直接用于导入到clion进行调试.而不用生成CMakeList.txt文件
具体参考: 又是一个引用

bear make all

......

16 warnings

## Finished docs (build time 00:01:29)

----- Build times -------
Start 2022-02-15 20:55:03
End   2022-02-15 21:01:37
00:00:15 corba
00:00:10 demos
00:01:29 docs
00:02:04 hotspot
00:00:14 images
00:00:10 jaxp
00:00:14 jaxws
00:01:26 jdk
00:00:23 langtools
00:00:09 nashorn
00:06:34 TOTAL
--------------

Finished building OpenJDK for target 'all'

此时你应该拥有一个自己编译好的JDK了.

评论

发表评论


取消