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库没有安装,根据你 ...
随机推荐
- 【UWP】UI适配整理
做UWP有几个月了,期间发布了几个应用,在这里整理一下适配相关的一些东西,UWP关于UI的适配主要有两种方式: 1.VisualState+Trigger:通过触发器出发界面更变,通常在Desktop ...
- Model元数据提供机制小结
在最开始先我得说说我看这部分的情况,最开始被各种ModelMetadata和各种ModelMetadataProvider给搞晕了,就几页书花了我好大的精力去看,直到后来看了一幅类图,细细看各个类之间 ...
- 【C#】妈妈再也不用担心自定义控件如何给特殊类型的属性添加默认值了,附自定义GroupBox一枚
------------------更新:201411190903------------------ 经过思考和实践,发现套路中的第1条是不必要的,就是完全可以不用定义一个名为Default+属性名 ...
- asp.net(c#)将彩色图片变灰阶图片
代码如下: using System; using System.Collections; using System.Configuration; using System.Data; using S ...
- 背水一战 Windows 10 (6) - 控件 UI: 字体的自动继承的特性, Style, ControlTemplate
[源码下载] 背水一战 Windows 10 (6) - 控件 UI: 字体的自动继承的特性, Style, ControlTemplate 作者:webabcd 介绍背水一战 Windows 10 ...
- 孙鑫MFC学习笔记13:文档
1.CArchive类保存内存数据 2.CAchive类重载了>>与<<操作符,类似C++文件流 3.在OnNewDocument中通过SetTitle设置标题 4.字符串资源 ...
- Java 读取Properties文件时应注意的路径问题
1. 使用Class的getResourceAsStream()方法读取Properties文件(资源文件)的路径问题: InputStream in = this.getClass().getRe ...
- expect笔记
#!/usr/bin/expect -f set ip [lindex $argv 0]; set password [lindex $argv 1]; set timeout 1 spawn ss ...
- python 实现登陆接口
要求: 1.输入用户名密码 2.认证成功后显示欢迎信息 3.输入三次后,锁定账户 流程图: 代码实现: #!/usr/bin/env python #!-*- coding:utf-8 -*- #!- ...
- mysql经纬度查询并且计算2KM范围内附近用户的sql查询性能优化实例教程
之前很傻很天真地以为无非就是逐个计算距离,然后比较出来就行了,然后当碰到访问用户很多,而且数据库中经纬度信息很多的时候,计算量的迅速增长,能让服务器完全傻逼掉,还是老前辈的经验比我们丰富,给了我很大的 ...