Unbuntu_14.04编译openjdk7
今天有问题需要研究一下JVM,但系统挂了,只能重装。在ubuntu下再次编译JDK,大约2个半小时,将遇到的问题笔记整理一下。
1.下载Openjdk Source Code
我用的是http://download.java.net/openjdk/jdk7。(一般https://jdk7.java.net/source.html也可以,但遇到的问题不一样)
2.依赖安装
我的镜像源选择的是中科大镜像:mirrors.ustc.edu.cn(在super->software&update->点击download from后面的选择->china->mirrors.ustc.edu.cn)
apt-get update
apt-get install build-essential gawk m4 libasound2-dev libcups2-dev libxrender-dev xorg-dev xutils-dev xllproto-print-dev binutils libmotif3 libmotif-dev ant
我不用openjdk做bootstrap JDK,编译的时候有Bug,建议使用Oracle JDK,我用的是1.7.0_80,去官方网站JDK->JDK Archive中JDK 7下载的。
如果上面第二条命令出现问题,可以换163,阿里云的镜像试试,实在不行,去pkgs.org下载失败的deb(Ubuntu14.04),使用dpkg -i software_name 安装。
3.环境变量
根据自己的路径设置有些地方可能需要修改:
export LANG=C
export ALT_BOOTDIR=/home/softwares/jdk1.7.0_80/ # Automatically download dependacies
export ALLOW_DOWNLOADS=true # 并行编译线程数,与CPU核数一致
export HOTSPOT_JOBS=8
export ALT_PARALLEL_COMPILE_JOBS=8 #
export SKIP_COMPARE_IMGAGES=true #
export USE_PRECOMPILED_HEADER=true # Compiling contents
export BUILD_LANGTOOLS=true
export BUILD_HOTSOPT=true
export BUILD_JDK=true # Compiling version # Avoid javaws & applet build
BUILD_DEPLOY=false # Avoid installation build
BUILD_INSTALL=false # Result ouput
export ALT_OUTPUTDIR=/home/advance/JVM/jdkBuild/openjdk_7/build # Necessity
unset JAVA_HOME
unset CLASSPATH
以上设置成功,在openjdk源码文件夹下:
make sanity 一次过。
4.编译make
在openjdk源码文件夹下:
#Ubuntu14.04居然check不同过,有点晕,只能加参数
make DISABLE_HOTSPOT_OS_VERSION_CHECK=OK
遇到的其他错误及解决方案:
1-----------------------------------------------------------------------------------------
ERROR: echo "*** This OS is not supported:" 'uname -a'; exit 1;
make DISABLE_HOTSPOT_OS_VERSION_CHECK=OK
2-----------------------------------------------------------------------------------------
/openjdk/hotspot/srcmps/constantPoolOop.cpp:272:39: error: converting 'false' to pointer type 'methodOop'
修改/openjdk/hotspot/src/share/vm/oops/constantPoolOop.cpp 第272行 return false改为return (methodOop)false; 或者 return NULL;
3-----------------------------------------------------------------------------------------
openjdk/hotspot/srcm/opto/loopnode.cpp:896:50: error: converting 'false' to pointer type 'Node*
SOLUTION: 修改openjdk/hotspot/src/share/vm/opto/loopnode.cpp: 第896行 return false改为return (Node*)false; 或者 return NULL;
4-----------------------------------------------------------------------------------------
Error occurred during initialization of VM Unable to load native library: /home/softwaresk1.8.0_101/jre/lib/amd64/libjava.so: symbol JVM_GetClassTypeAnnotations, version SUNWprivate_1.1 not defined in file libjvm.so with link time reference
SOLUTION: openjdk/hotspot/make/linux/Makefile 去掉所有的 && ./test_gamma
5-----------------------------------------------------------------------------------------
/home/mengxiansen/openjdk/openjdk/hotspot/src/share/vm/runtime/interfaceSupport.hpp:430:0: error: "__LEAF" redefined [-Werror]
SOLUTION:
#define __LEAF(result_type, header)
/usr/include/x86_64-linux-gnu/sys/cdefs.h:42:0: note: this is the location of the previous definition
# define __LEAF , __leaf__
在interfaceSupport.hpp增加
#ifdef __LEAF
#undef __LEAF
#define __LEAF(result_type, header) \
TRACE_CALL(result_type, header) \
debug_only(NoHandleMark __hm;) \
/* begin of body */
#endif
6-----------------------------------------------------------------------------------------
gcc: error: unrecognized command line option '-mimpure-text'
SOLUTION: gcc版本问题,这个命令在本机所用的4.7.2版的gcc中已经去除,既然不能降低gcc版本(本机ubuntu12.10内核用4.7.2版gcc编译),那就在openjdk/jdk/make/common/shared/Compiler-gcc.gmk 中去掉-mimpure-text命令
7-----------------------------------------------------------------------------------------
Error: time is more than 10 years from present: 1136059200000
SOLUTION: 将 openjdk/jdk/src/share/classes/java/util/CurrencyData.properties 中所有的时间改为10年以内
8-----------------------------------------------------------------------------------------
collect2: error: ld returned 1 exit status
SOLUTION: openjdk/jdk/make/javax/sound/jsoundalsa/Makefile 里面
刪除 LDFLAGS += -lasound
加入 OTHER_LDLIBS += -lasound
5.编译成功
-- Build times ----------
Target all_product_build
Start 2016-08-31 22:10:08
End 2016-08-31 22:13:49
00:00:02 corba
00:00:02 hotspot
00:00:01 jaxp
00:00:02 jaxws
00:03:33 jdk
00:00:01 langtools
00:03:41 TOTAL
-------------------------
make[1]: Leaving directory `/home/softwares/openjdk7'
JVM在/home/advance/JVM/jdkBuild/openjdk_7/build/hotspot/outputdir/linux_amd64_compiler2/product,可以在IDE工具中进行调试。
在ALT_OUTPUTDIR的build下面找类似的路径linux_amd64_complier2是我的ubuntu64位系统,别的系统不一样。
以上记录在github中 https://github.com/dreamingodd/UnderstandingJVM ,其他问题可以去找来参考。
dreamingodd原创文章,如转载请注明出处。
Unbuntu_14.04编译openjdk7的更多相关文章
- Ubuntu16.04 编译 OpenJDK7
<深入理解Java虚拟机>第二版第一章实践 准备 Mercurial sudo apt-get install mercurial OpenJDK7 hg clone http://hg. ...
- Ubuntu16.04编译Android6.0/cm13.0教程及相关错误解决办法
一.必备工作 1.安装依赖库 sudo apt--dev libesd0-dev git-core gnupg flex bison gperf build-essential zip curl zl ...
- ubuntu10.04编译安装LAMP
ubuntu10.04编译安装LAMP以及简单wordpress的使用 : http://linuxme.blog.51cto.com/1850814/971631 一.源码安装LAMP 网上有一堆关 ...
- Ubuntu14.04编译安装mysql5.6.26
Ubuntu14.04编译安装mysql5.6.26 (1)安装编译源码需要的包 sudo apt-get install make cmake gcc g++ bison libncurses5-d ...
- MTK6577+Android4.04编译
MTK6577+Android4.04编译 编译命令 ./mk new 出错信息如下: **********checkingEnv************ Your building environm ...
- 对<< ubuntu 12.04编译安装linux-3.6.10内核笔记>>的修正
前题: 在前几个月的时候,写了一篇笔记,说的是kernel compile的事情,当时经验不足,虽说编译过了,但有些地方写的有错误--因为当时的理解是有错误的.今天一一更正,记录如下: 前文笔记链接: ...
- Ubuntu16.04编译安装php
#Ubuntu16.04编译安装php Ubuntu16.04上面搭建基于Nginx的php服务.Nginx使用apt直接安装的. sudo apt install nginx php的安装部署步骤主 ...
- Ubuntu12.04编译Android4.0.1源码全过程-----附wubi安装ubuntu编译android源码硬盘空间不够的问题解决
昨晚在编译源码,make一段时间之后报错如下: # A fatal error has been detected by the Java Runtime Environment: # # SIGSE ...
- ubuntu16.04 编译出错:fatal error: SDL/SDL.h: No such file or directory
在ubuntu 16.04编译神经网络代码时候,遇到了这样一种错误? fatal error: SDL/SDL.h: No such file or directory 原因是SDL库没有安装,根据你 ...
随机推荐
- OS初识
参考: 操作系统的故事(1-4):
- Entity Framework 的简单介绍与实例
1.下载与引用 a) 首先需要下载一个oracle clinent 12c 发行版(我这边下载的是发行版)并进行安装,下载内容如下图 B) 创建一个项目,通过Nuget引用 添加ODP.NET ...
- web工程依赖的问题
http://blog.csdn.net/testcs_dn/article/details/43764497 做个记录
- mysql学习笔记 第六天
改变数据表的结构: alter table tb_name action,[action,action](使用alter table 之前,需要查看数据表的当前定义,需要执行show create t ...
- UVA 11582 Colossal Fibonacci Numbers! 大斐波那契数
大致题意:输入两个非负整数a,b和正整数n.计算f(a^b)%n.其中f[0]=f[1]=1, f[i+2]=f[i+1]+f[i]. 即计算大斐波那契数再取模. 一开始看到大斐波那契数,就想到了矩阵 ...
- java 用 jxl poi 进行excel 解析 *** 最爱那水货
/** * 解析excel文件 ,并把数据放入数组中 格式 xlsx xls * @param path 从ftp上下载到本地的文件的路径 * @return 数据数组集合 */ public Lis ...
- VS code 安装react-native代码提醒
上GitHub:https://github.com/Microsoft/vscode-react-native Getting started Install VS Code (0.10.10+ i ...
- CSS3背景温故
1.背景的五种基本属性background-color(背景颜色)background-image(背景图片)background-repeat(背景图片展示方式)background-attachm ...
- apache EnableMMAP指令
官方说明地址:http://httpd.apache.org/docs/2.4/mod/core.html#enablemmap Use memory-mapping to read files du ...
- SAP中删除假脱机请求
好几次公司的SAP都碰到所有的SMARTFORM都打印不了的情况.查了一下原因原来是假脱机请求太多了.清了一下,问题就解决了. 删除假脱机请求的一些方法: 1.避免经常出现此类错误,最好还 ...