Linux 下编译openjdk

操作系统ubuntu14.04

openjdk版本 7u4

openjdk7u4可以在https://jdk7.java.net/source.html下载

一.构建编译环境

sudo apt-get install build-essential gawk m4 openjdk-6-jdk
libasound2-dev libcups2-dev libxrender-dev xorg-dev xutils-dev
x11proto-print-dev binutils libmotif3 libmotif-dev ant

二.设置环境变量

export LANG=C

#编译openjdk7所需要的jdk目录
export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk-amd64

export ALLOW_DOWNLOADS=true
export USE_PRECOMPILED_HEADER=true
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export DEBUG_NAME=debug

unset CLASSPATH
unset JAVA_HOME

三.检查设置是否正确

在终端输入make sanity

  1 ( cd  ./jdk/make &&   2       make sanity HOTSPOT_IMPORT_CHECK=false JDK_TOPDIR=/home/foreverenjoy/Program/openjdk/jdk JDK_MAKE_SHARED_DIR=/home/foreverenjoy/Program/openjdk/jdk/make/common/shared EXTERNALSANITYCONTROL=true SOURCE_LANGUAGE_VERSION=7 TARGET_CLASS_VERSION=7 MILESTONE=internal BUILD_NUMBER=b00 JDK_BUILD_NUMBER=b00 FULL_VERSION=1.7.0-internal-debug-foreverenjoy_2016_07_03_19_04-b00 PREVIOUS_JDK_VERSION=1.6.0 JDK_VERSION=1.7.0 JDK_MKTG_VERSION=7 JDK_MAJOR_VERSION=1 JDK_MINOR_VERSION=7 JDK_MICRO_VERSION=0 PREVIOUS_MAJOR_VERSION=1 PREVIOUS_MINOR_VERSION=6 PREVIOUS_MICRO_VERSION=0 ARCH_DATA_MODEL=64 VARIANT=DBG DEBUG_CLASSFILES=true COOKED_BUILD_NUMBER=0 ALT_OUTPUTDIR=/home/foreverenjoy/Program/openjdk/build/linux-amd64 ALT_LANGTOOLS_DIST=/home/foreverenjoy/Program/openjdk/build/linux-amd64/langtools/dist ALT_CORBA_DIST=/home/foreverenjoy/Program/openjdk/build/linux-amd64/corba/dist ALT_JAXP_DIST=/home/foreverenjoy/Program/openjdk/build/linux-amd64/jaxp/dist ALT_JAXWS_DIST=/home/foreverenjoy/Program/openjdk/build/linux-amd64/jaxws/dist ALT_HOTSPOT_IMPORT_PATH=/home/foreverenjoy/Program/openjdk/build/linux-amd64/hotspot/import BUILD_HOTSPOT=true ; )
  3 INFO: ENABLE_FULL_DEBUG_SYMBOLS=1
  4 INFO: /usr/bin/objcopy cmd found so will create .debuginfo files.
  5 INFO: STRIP_POLICY=min_strip
  6 INFO: ZIP_DEBUGINFO_FILES=1
  7 make[1]: Entering directory `/home/foreverenjoy/Program/openjdk/jdk/make‘
  8 INFO: ENABLE_FULL_DEBUG_SYMBOLS=1
  9 INFO: /usr/bin/objcopy cmd found so will create .debuginfo files.
 10 INFO: STRIP_POLICY=min_strip
 11 INFO: ZIP_DEBUGINFO_FILES=1
 12 make[1]: Leaving directory `/home/foreverenjoy/Program/openjdk/jdk/make‘
 13
 14 Build Machine Information:
 15    build machine = foreverenjoy
 16
 17 Build Directory Structure:
 18    CWD = /home/foreverenjoy/Program/openjdk
 19    TOPDIR = .
 20    LANGTOOLS_TOPDIR = ./langtools
 21    JAXP_TOPDIR = ./jaxp
 22    JAXWS_TOPDIR = ./jaxws
 23    CORBA_TOPDIR = ./corba
 24    HOTSPOT_TOPDIR = ./hotspot
 25    JDK_TOPDIR = ./jdk
 26
 27 Build Directives:
 28    BUILD_LANGTOOLS = true
 29    BUILD_JAXP = true
 30    BUILD_JAXWS = true
 31    BUILD_CORBA = true
 32    BUILD_HOTSPOT = true
 33    BUILD_JDK    = true
 34    DEBUG_CLASSFILES =
 35    DEBUG_BINARIES =
 36
 37 Hotspot Settings:
 38       HOTSPOT_BUILD_JOBS  =
 39       HOTSPOT_OUTPUTDIR   = /home/foreverenjoy/Program/openjdk/build/linux-amd64/hotspot/outputdir
 40       HOTSPOT_EXPORT_PATH = /home/foreverenjoy/Program/openjdk/build/linux-amd64/hotspot/import
 41
 42
 43
 44
 45 Bootstrap Settings:
 46   BOOTDIR = /usr/lib/jvm/java-6-openjdk-amd64
 47     ALT_BOOTDIR = /usr/lib/jvm/java-6-openjdk-amd64
 48   BOOT_VER = 1.6.0 [requires at least 1.6]
 49   OUTPUTDIR = /home/foreverenjoy/Program/openjdk/build/linux-amd64
 50     ALT_OUTPUTDIR = /home/foreverenjoy/Program/openjdk/build/linux-amd64
 51   ABS_OUTPUTDIR = /home/foreverenjoy/Program/openjdk/build/linux-amd64
 52
 53 Build Tool Settings:
 54   SLASH_JAVA = /NOT-SET
 55     ALT_SLASH_JAVA =
 56   VARIANT = DBG
 57   JDK_DEVTOOLS_DIR = /NOT-SET/devtools
 58     ALT_JDK_DEVTOOLS_DIR =
 59   ANT_HOME =
 60   UNIXCOMMAND_PATH = /bin/
 61     ALT_UNIXCOMMAND_PATH =
 62   COMPILER_PATH = /usr/bin/
 63     ALT_COMPILER_PATH =
 64   DEVTOOLS_PATH = /usr/bin/
 65     ALT_DEVTOOLS_PATH =
 66   UNIXCCS_PATH = /usr/ccs/bin/
 67     ALT_UNIXCCS_PATH =
 68   USRBIN_PATH = /usr/bin/
 69     ALT_USRBIN_PATH =
 70   COMPILER_NAME = GCC4
 71   COMPILER_VERSION = GCC4
 72   CC_VER = 4.8 [requires at least 4.3.0]
 73   ZIP_VER = 3.0 [requires at least 2.2]
 74   UNZIP_VER = 6.00 [requires at least 5.12]
 75   ANT_VER = 1.9.3 [requires at least 1.7.1]
 76   TEMPDIR = /home/foreverenjoy/Program/openjdk/build/linux-amd64/tmp
 77
 78 Build Directives:
 79   OPENJDK = true
 80   USE_HOTSPOT_INTERPRETER_MODE =
 81   PEDANTIC =
 82   DEV_ONLY =
 83   NO_DOCS =
 84   NO_IMAGES =
 85   TOOLS_ONLY =
 86   INSANE =
 87   COMPILE_APPROACH = parallel
 88   PARALLEL_COMPILE_JOBS = 2
 89     ALT_PARALLEL_COMPILE_JOBS =
 90   FASTDEBUG =
 91   COMPILER_WARNINGS_FATAL = false
 92   COMPILER_WARNING_LEVEL =
 93   SHOW_ALL_WARNINGS =
 94   INCREMENTAL_BUILD = false
 95   CC_HIGHEST_OPT =
 96   CC_HIGHER_OPT =
 97   CC_LOWER_OPT =
 98   CXXFLAGS =  -g -fPIC -DCC_NOEX -W -Wall  -Wno-unused -Wno-parentheses -fno-omit-frame-pointer -D_LITTLE_ENDIAN
 99   CFLAGS =  -g   -fno-strict-aliasing -fPIC -W -Wall  -Wno-unused -Wno-parentheses -pipe -fno-omit-frame-pointer -D_LITTLE_ENDIAN
100   BOOT_JAVA_CMD = /usr/lib/jvm/java-6-openjdk-amd64/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m
101   BOOT_JAVAC_CMD = /usr/lib/jvm/java-6-openjdk-amd64/bin/javac  -J-XX:ThreadStackSize=1536 -J-XX:-PrintVMOptions -J-XX:+UnlockDiagnosticVMOptions -J-XX:-LogVMOutput -J-Xmx512m -J-Xms512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -encoding ascii -source 6 -target 6 -XDignore.symbol.file=true
102   BOOT_JAR_CMD = /usr/lib/jvm/java-6-openjdk-amd64/bin/jar
103   BOOT_JARSIGNER_CMD = /usr/lib/jvm/java-6-openjdk-amd64/bin/jarsigner
104   JAVAC_CMD = /NOT-SET/re/jdk/1.7.0/promoted/latest/binaries/linux-amd64/bin/javac  -J-XX:ThreadStackSize=1536 -J-XX:-PrintVMOptions -J-XX:+UnlockDiagnosticVMOptions -J-XX:-LogVMOutput -J-Xmx512m -J-Xms512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m  -g -source 7 -target 7 -encoding ascii -Xbootclasspath:/home/foreverenjoy/Program/openjdk/build/linux-amd64/classes
105   JAVAH_CMD = /NOT-SET/re/jdk/1.7.0/promoted/latest/binaries/linux-amd64/bin/javah -bootclasspath /home/foreverenjoy/Program/openjdk/build/linux-amd64/classes
106   JAVADOC_CMD = /NOT-SET/re/jdk/1.7.0/promoted/latest/binaries/linux-amd64/bin/javadoc -J-XX:-PrintVMOptions -J-XX:+UnlockDiagnosticVMOptions -J-XX:-LogVMOutput -J-Xmx512m -J-Xms512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -bootclasspath /home/foreverenjoy/Program/openjdk/build/linux-amd64/classes
107
108 Build Platform Settings:
109   USER = foreverenjoy
110   PLATFORM = linux
111   ARCH = amd64
112   LIBARCH = amd64
113   ARCH_FAMILY = amd64
114   ARCH_DATA_MODEL = 64
115   ARCHPROP = amd64
116   ALSA_VERSION = 1.0.27.2
117   OS_VERSION = 3.19.0-59-generic [requires at least 2.6]
118   OS_VARIANT_NAME = Ubuntu
119   OS_VARIANT_VERSION = 14.04
120   MB_OF_MEMORY = 7555
121
122 GNU Make Settings:
123   MAKE = make
124   MAKE_VER = 3.81 [requires at least 3.81]
125   MAKECMDGOALS = sanity
126   MAKEFLAGS = w
127   SHELL = /bin/sh
128
129 Target Build Versions:
130   JDK_VERSION = 1.7.0
131   MILESTONE = internal
132   RELEASE = 1.7.0-internal-debug
133   FULL_VERSION = 1.7.0-internal-debug-foreverenjoy_2016_07_03_19_04-b00
134   BUILD_NUMBER = b00
135
136 External File/Binary Locations:
137   USRJDKINSTANCES_PATH = /opt/java
138   BUILD_JDK_IMPORT_PATH = /NOT-SET/re/jdk/1.7.0/promoted/latest/binaries
139     ALT_BUILD_JDK_IMPORT_PATH =
140   JDK_IMPORT_PATH = /NOT-SET/re/jdk/1.7.0/promoted/latest/binaries/linux-amd64
141     ALT_JDK_IMPORT_PATH =
142   LANGTOOLS_DIST =
143     ALT_LANGTOOLS_DIST = /home/foreverenjoy/Program/openjdk/build/linux-amd64/langtools/dist
144   CORBA_DIST =
145     ALT_CORBA_DIST = /home/foreverenjoy/Program/openjdk/build/linux-amd64/corba/dist
146   JAXP_DIST =
147     ALT_JAXP_DIST = /home/foreverenjoy/Program/openjdk/build/linux-amd64/jaxp/dist
148   JAXWS_DIST =
149     ALT_JAXWS_DIST = /home/foreverenjoy/Program/openjdk/build/linux-amd64/jaxws/dist
150   HOTSPOT_DOCS_IMPORT_PATH = /NO_DOCS_DIR
151     ALT_HOTSPOT_DOCS_IMPORT_PATH =
152   HOTSPOT_IMPORT_PATH = /home/foreverenjoy/Program/openjdk/build/linux-amd64/hotspot/import
153     ALT_HOTSPOT_IMPORT_PATH = /home/foreverenjoy/Program/openjdk/build/linux-amd64/hotspot/import
154   HOTSPOT_SERVER_PATH = /home/foreverenjoy/Program/openjdk/build/linux-amd64/hotspot/import/jre/lib/amd64/server
155     ALT_HOTSPOT_SERVER_PATH =
156   CACERTS_FILE = ./../src/share/lib/security/cacerts
157     ALT_CACERTS_FILE =
158   CUPS_HEADERS_PATH = /usr/include
159     ALT_CUPS_HEADERS_PATH =
160
161 OpenJDK-specific settings:
162   FREETYPE_HEADERS_PATH = /usr/include
163     ALT_FREETYPE_HEADERS_PATH =
164   FREETYPE_LIB_PATH = /usr/lib
165     ALT_FREETYPE_LIB_PATH =
166
167 Previous JDK Settings:
168   PREVIOUS_RELEASE_PATH = USING-PREVIOUS_RELEASE_IMAGE
169     ALT_PREVIOUS_RELEASE_PATH =
170   PREVIOUS_JDK_VERSION = 1.6.0
171     ALT_PREVIOUS_JDK_VERSION =
172   PREVIOUS_JDK_FILE =
173     ALT_PREVIOUS_JDK_FILE =
174   PREVIOUS_JRE_FILE =
175     ALT_PREVIOUS_JRE_FILE =
176   PREVIOUS_RELEASE_IMAGE = /usr/lib/jvm/java-6-openjdk-amd64
177     ALT_PREVIOUS_RELEASE_IMAGE =
178
179
180 Sanity check passed.

如果看到"Sanity check passend.",说明检查通过。

四.开始编译

在终端输入make

等一段时间

#-- Build times ----------
Target debug_build
Start 2016-07-03 19:25:12
End   2016-07-03 19:41:06
00:01:19 corba
00:05:24 hotspot
00:00:15 jaxp
00:00:18 jaxws
00:08:11 jdk
00:00:27 langtools
00:15:54 TOTAL
-------------------------

编译完成

在OpenJDK目录下有个build文件夹是编译的output文件夹

[email protected]:~/Program/openjdk$ cd build/
[email protected]:~/Program/openjdk/build$ ls -l
total 8
drwxrwxr-x 29 foreverenjoy foreverenjoy 4096  7月  3 19:41 linux-amd64
drwxrwxr-x 28 foreverenjoy foreverenjoy 4096  7月  3 19:25 linux-amd64-debug
[email protected]:~/Program/openjdk/build$ cd linux-amd64/bin/
[email protected]:~/Program/openjdk/build/linux-amd64/bin$ ./java -version
openjdk version "1.7.0-internal-debug"
OpenJDK Runtime Environment (build 1.7.0-internal-debug-foreverenjoy_2016_07_03_19_19-b00)
OpenJDK 64-Bit Server VM (build 24.0-b56-jvmg, mixed mode)

编译结果

五.遇到的问题

1.

make[6]: Leaving directory /usr/local/openjdk/build/linux-amd64-debug/hotspot/outputdir/linux_amd64_compiler2/jvmg‘
cd linux_amd64_compiler2/jvmg && ./test_gamma
Using java runtime at: /usr/lib/jvm/java-1.6.0-openjdk.x86_64/jre
./gamma: relocation error: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/amd64/libjava.so: symbol JVM_FindClassFromCaller, version SUNWprivate_1.1 not defined in file libjvm.so with link time reference
make[5]: *** [jvmg] Error 127
make[5]: Leaving directory/usr/local/openjdk/build/linux-amd64-debug/hotspot/outputdir‘ make[4]: * [generic_build2] Error 2 make[4]: Leaving directory /usr/local/openjdk/hotspot/make‘
make[3]: *** [jvmg] Error 2
make[3]: Leaving directory/usr/local/openjdk/hotspot/make‘ make[2]: * [hotspot-build] Error 2 make[2]: Leaving directory /usr/local/openjdk‘
make[1]: *** [generic_debug_build] Error 2
make[1]: Leaving directory/usr/local/openjdk‘

symbol JVM_FindClassFromCaller, version SUNWprivate_1.1 not defined in file libjvm.so with link time reference

删除hotspot/make/linux/Makefile中所有的test_gamma ( 即删掉所有的&& ./test_gamma)

2.

m -XX:MaxPermSize=160m -jar /home/foreverenjoy/Program/openjdk/build/linux-amd64/../linux-amd64-debug/btjars/generatecurrencydata.jar -o /home/foreverenjoy/Program/openjdk/build/linux-amd64/../linux-amd64-debug/lib/currency.data.temp         < ../../../src/share/classes/java/util/CurrencyData.properties
Error: time is more than 10 years from present: 1136059200000
java.lang.RuntimeException: time is more than 10 years from present: 1136059200000
    at build.tools.generatecurrencydata.GenerateCurrencyData.makeSpecialCaseEntry(GenerateCurrencyData.java:285)
    at build.tools.generatecurrencydata.GenerateCurrencyData.buildMainAndSpecialCaseTables(GenerateCurrencyData.java:225)
    at build.tools.generatecurrencydata.GenerateCurrencyData.main(GenerateCurrencyData.java:154)
make[5]: *** [/home/foreverenjoy/Program/openjdk/build/linux-amd64/../linux-amd64-debug/lib/currency.data] Error 1
make[5]: Leaving directory `/home/foreverenjoy/Program/openjdk/jdk/make/java/java‘
make[4]: *** [all] Error 1
make[4]: Leaving directory `/home/foreverenjoy/Program/openjdk/jdk/make/java‘
make[3]: *** [all] Error 1
make[3]: Leaving directory `/home/foreverenjoy/Program/openjdk/jdk/make‘
make[2]: *** [jdk-build] Error 2
make[2]: Leaving directory `/home/foreverenjoy/Program/openjdk‘
make[1]: *** [generic_debug_build] Error 2
make[1]: Leaving directory `/home/foreverenjoy/Program/openjdk‘
make: *** [build_debug_image] Error 2

time is more than 10 years from present: 1136059200000

将CurrencyData.properties内的时间改为10年内

时间: 2024-11-12 17:37:41

Linux 下编译openjdk的相关文章

在linux下编译openjdk7

最近刚开始看<深入理解JAVA虚拟机>这本书.第一章的实践是自己手动编译openjdk7,但书上的步骤都是基于windows的,于是在网上搜了一下linux下编译openjdk的资料: http://blog.csdn.net/kindazrael/article/details/7266314 http://guoh.org/lifelog/2011/05/compile-openjdk-by-yourself/ 这辆篇文章都说的比较详细.其实,最好的文档是openjdk源码包中的READM

linux下编译php追加enable的方法

如果我们运行php时发现缺少某个库,在windows环境下很简单,找到.dll 对应的库文件,然后拷贝到 extension 目录下,然后在php.ini 里 去掉 前面的分号或者 追加一行 extension = XXXX.dll 即可. linux环境下,可不是像windows环境下那么的简单. 下面我们已 sysvmsg 这个库文件的安装为例 来详细说明php的编译方法 收件进入php的原始文件 比如我是下载在这个路径下: [[email protected] php-5.2.17]# c

linux下编译qt5.6.0静态库——configure配置

 随笔 - 116  文章 - 4  评论 - 7 linux下编译qt5.6.0静态库--configure配置 linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberry选项: Android 选项: 生成makefile 遇到链接检查失败的情况 生成makefile后进行编译 编译时的错误 多重定义'QT_MODBUS()'和'QT_MODBU

linux下编译安装php各种报错大集合

PHP开源脚本语言 PHP(外文名: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,入门门槛较低,易于学习,使用广泛,主要适用于Web开发领域.PHP的文件后缀名为php. 本文为大家整理汇总了一些linux下编译安装php各种报错大集合 ,感兴趣的同学参考下. 报错1:make 后报错如下: Generating phar.php /home/oldboy/tools/php-5.3.27

Linux下编译ffmpeg

Linux下编译ffmpeg太简单了. 1.下载yasm 1-1. 下载地址:http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz 1-2. 解压缩: tar zxvf yasm-1.3.0.tar.gz 1-3. cd yasm-1.3.0进入 1-4. 命令行执行./configure 检测环境并生成Makefile文件 1-5. 执行make编译,sudo make install安装 2. 下载ffmpeg 2-1

Linux下编译安装qemu和libvirt

目录 [hide] 1 安装qemu 1.1 qemu介绍 1.2 下载源文件 1.3 编译安装 2 安装libvirt 2.1 libvirt介绍 2.2 下载libvirt 2.3 编译安装 3 参考资料 KVM虚拟机(英语:Kernel-based Virtual Machine),是一种用于Linux内核中的虚拟化基础设施.KVM目前支援Intel VT及AMD-V的原生虚拟技术.KVM在2007年2月被导入Linux 2.6.20核心中.它也被引入FreeBSD.在Mac OS X中,

[转载]linux下编译php中configure参数具体含义

编译N次了   原来这么回事 原文地址:linux下编译php中configure参数具体含义作者:捷心特 php编译参数的含义 ./configure –prefix=/usr/local/php                      php 安装目录 –with-apxs2=/usr/local/apache/bin/apxs –with-config-file-path=/usr/local/php/etc      指定php.ini位置 –with-mysql=/usr/local

【转】Linux下编译ffmpeg

1.下载ffmpeg.下载网址:http://www.ffmpeg.org/download.html 2.解压缩tar -zxvf ffmpeg-2.0.1.tar.gz 3.配置,生成Makefile./configure --enable-shared --disable-yasm --prefix=/usr/local/ffmpeg如果执行结果不对,可以根据提示信息,并查看帮助,解决问题./configure --help 4.编译安装makemake install 5.安装之后在/u

linux下编译安装boost库

转载:http://www.cnblogs.com/oloroso/p/4632848.html linux下编译安装boost库 linux下编译安装boost库 1.下载并解压boost 1.58 源代码 下载 解压 2.运行bootstrap.sh 3.使用b2进行构建 构建成功的提示 4.安装boost库到指定目录 5.测试一下 代码 编译运行 先看一下系统环境 Linux o-pc 3.19.0-22-generic #22-Ubuntu SMP Tue Jun 16 17:15:15