上周末在
JavaEye问答频道看到这样一个问题:
JVM源码编译
liueye 写道
请问有谁在Linux环境编译过SUN JVM,请提供编译手顺,谢谢
于是回答一下…
背景知识
这年头想从JRL源码来构建JDK的应该不多了吧。毕竟Sun(-> Oracle)的JDK开源源码的主流早已是
OpenJDK。
如果要尝试构建基于Sun源码的JDK,强烈建议优先考虑OpenJDK。选择它有诸多好处:
1、它的核心代码与同时期Sun(-> Oracle)的产品版基本上是一样的,血统纯正,不用担心性能问题,也基本上没什么兼容性问题;
(代码上最主要的差异是在原本JDK依赖的第三方库上,包括加密库、音频库、字体等。核心部分,也就是HotSpot VM与Java核心库基本上保持了Sun JDK的原貌,甚至还比Sun JDK更快的吸收社区反馈的贡献)
2、它是真正开源的,许可证是
GPLv2+CE,使用上比原本JDK的另外两种许可证要自由一些;
3、由于考虑到社区的开发者的build环境需求,OpenJDK的构建系统比原本的JDK有大幅改进,使整个build过程变得非常轻松。
如果要构建OpenJDK 6,参考
OpenJDK 6 Build README即可。
在Ubuntu或其他Debian系的Linux上只要靠aptitude build-dep openjdk-6就能抓到大部分需要的依赖包,相当轻松。
OpenJDK 6 Build README 写道
After installing Ubuntu 9.04 you need to install several build dependencies. The simplest way to do it is to execute the following commands:
sudo aptitude build-dep openjdk-6
sudo aptitude install openjdk-6-jdk gcc-4.2 g++-4.2
sudo aptitude install libmotif-dev
In addition, it's necessary to set a few environment variables for the build:
export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
Then, calling make in the top level OpenJDK source code directory with the following parameters results in a working build:
make all CC=gcc-4.2 CPP=g++-4.2
(注:没有aptitude的话把上面的代码改为用apt-get就行
另外,实际build的时候发觉如果JAXP和JAXWS出问题的话只要再多来个export ALLOW_DOWNLOADS=true就好了。
OpenJDK6 build 20及之前的版本的CORBA要build起来可能有点麻烦,没用到的话直接BUILD_CORBA=false吧。另外现在java.net迁移了之后,这些版本里jaxp.properties和jaxwa.properties里的下载地址不对了,要修正)
在OpenJDK之外,Sun确实也有以别的许可证形式提供JDK的源码。
其中一种是
Sun Community Source License (SCSL)。这与微软在公布其.NET的虚拟机CLR的部分实现——
SSCLI所使用的许可证有相似之处。Sun从1998年12月开始就通过SCSL许可证公布了许多产品的源码,包括全线JDK源码,一直到
JDK 5.0。
SCSL的可操作性一直受到社区的诟病,所以从JDK 5.0开始,Sun开始使用一种新的许可证,
Java Research License (JRL)来公布其源码,主要用于面向研究人员提供JDK源码。
由于这两种许可证的使用限制都比较大,并不是真正意义上的“开源”(大写的Open Source),所以在OpenJDK出来之后,以这两种许可证公布的源码已经越来越不受关注。
根据上个月的一则新闻,
Retiring JDK Source Code Bundles Under JRL,以后Oracle JDK将不会再以JRL许可证发布源码,只保留以GPLv2+CE许可证发布OpenJDK源码。
更新(2011-02-04):几天前刚出的
JDK6u25 build 01的源码果然就没有继续以JRL许可证
公开发布了。
但既然写了这一帖,肯定还是有人想直接拿JRL许可证公布的Sun JDK源码来build的。就让我们来看看要build出其中的大部分需要怎样的环境,要做哪些事情吧。
参考文档
·
README: JDK Builds (JDK v6u23 fcs)
·
Kelly O'Hair: JDK6 Build Cheat Sheet
·
Noniko's Weblog: Solaris - maybe the easiest environment to build JDK (重点在帖后Kelly O'Hair的回复中)
有篇老文虽然没参考上不过还是把链接记下来吧:
Cay Horstmann: Honey, I built the JDK! (on Ubuntu)
另外,同事
大仁先前也询问过build JDK的事。他build的是OpenJDK 7,笔记在这里:
Ubuntu10.04下build OpenJDK7 的过程
构建的目标
本帖要build出来的内容主要为研究、开发目的服务,而不用于再发布。因此不把整个Sun JDK里的所有源码都build掉,可以避开一下非常麻烦的东西。
要build出来的部分包括:
·功能完整的HotSpot VM(libjvm.so等)
·功能完整的Java核心类库(rt.jar等)
·功能完整的JDK内建工具及其启动程序(j2sdk-image/bin目录里的)
引用
appletviewer javac jhat jstat rmic unpack200
apt javadoc jinfo jstatd rmid wsgen
extcheck javah jmap keytool rmiregistry wsimport
idlj javap jps native2ascii schemagen xjc
jar java-rmi.cgi jrunscript orbd serialver
jarsigner jconsole jsadebugd pack200 servertool
java jdb jstack policytool tnameserv
·由上述组件构成的JRE、JDK映像
·上述项目的product build及fastdebug build
不包括:
·
JAXP
·JAXWS
·
浏览器Java插件
·
VisualVM
·JDK或JRE的安装包
获取源码
要获取Oracle JDK的最新源码,可以在官网
Java SE Downloads页面找到“Java SE 6 JDK Source Code”的一栏,点击“Downlaod”链接即可跳转到当前JDK版本的源码下载页。
2012-06更新:这个链接已经无法下载到JRL许可证的JDK 6源码。下面也是。
本帖需要下载的包是这两个:
·JDK 6u23 Source under the
JRL license
jdk-6u23-fcs-src-b05-jrl-12_nov_2010.jar
·JDK Binaries for Source Build 6u23
jdk-6u23-fcs-bin-b05-jrl-12_nov_2010.jar
(顺带一提,FCS的意思是
Final Customer Shipment
引用
FCS (Final Customer Shipment)
the stage at which a product has completed the beta-testing phase and is available to be shipped to customers
)
如果想下载较早版本的JDK6源码,可以在
Java™ Platform, Standard Edition 6 Snapshot Releases Archive页面找到源码下载页的列表。
2012-06更新:同上,这个链接也已经无法下载到JRL许可证的JDK 6源码。
再次提醒注意:这些源码都是以
Java Research License (JRL)公布的,请确认自己的需求在许可证允许的范围内。
配置环境
我的主系统现在是
Ubuntu 10.10 x86_64,不过上面已经装了很多开发包,到底哪些是用来build JDK的我也不记得了。所以这次装了
VirtualBox 4,在上面装了个干净的
XUbuntu 10.10 x86专门用来实验。
本帖描述的build环境适用于当前主流版本的Ubuntu、XUbuntu和KUbuntu,也应该适用于许多
Debian系Linux。RPM系Linux需要自己找对应的软件包了。
从干净的XUbuntu安装开始,到最终能完成一次generic debug build,过程中安装了下列软件包:
引用
build-essential
gawk
m4
openjdk-6-jdk
libasound2-dev
libcups2-dev
libxrender-dev
xorg-dev
xutils-dev
x11proto-print-dev
一口气用apt-get把它们都装上就好了:
引用
$ sudo apt-get install build-essential gawk m4 openjdk-6-jdk libasound2-dev libcups2-dev libxrender-dev xorg-dev xutils-dev x11proto-print-dev
虽然我没通过apt-get显式安装binutils,但确认了这系统实际上有装过,如果build过程中有意外的错误的话请安装binutils:
引用
$ sudo apt-get install binutils
其中,
build-essential gawk m4 binutils:
这些是Linux上的一些基本工具,build许多东西都需要它们。build-essential主要用来装g++(GNU C++编译器)及C++标准库;gawk是GNU版awk,用来做文本操作;m4是一种模板语言,AWT的DebugHelper依赖它来生成部分源码;binutils主要是链接器、汇编器、反汇编器之类的。
openjdk-6-jdk:
要build JDK,需要先安装一个启动用的JDK(“
Bootstrap JDK”)。apt-get默认将它安装在/usr/lib/jvm/java-6-openjdk。build的时候要把ALT_BOOTDIR设置到它的安装目录上。这里装Sun JDK来做Bootstrap JDK也行。
libasound2-dev:
这是
Advanced Linux Sound Architecture (ALSA)相关的依赖。
libcups2-dev:
这是
Common UNIX Printing System (CUPS)相关的依赖。
libxrender-dev xorg-dev xutils-dev x11proto-print-dev:
这些全部都是X相关的依赖,主要是为了build出AWT的部分才会需要的。这部分依赖非常非常蛋疼。在安装完依赖后,还得造个符号链接,把/usr/lib映射为/usr/X11R6的别名,这样build过程才能正确找到X11的头文件:
引用
$ sudo mkdir /usr/X11R6
$ cd /usr/X11R6/
$ sudo ln -s -T /usr/lib lib
开始build
准备源码
在真正开始build之前,先把先前下载到的两个包,jdk-6u23-fcs-src-b05-jrl-12_nov_2010.jar 与 jdk-6u23-fcs-bin-b05-jrl-12_nov_2010.jar 解压到同一目录下,确保该目录有读写权限,并确认该目录有4G以上的剩余空间可用。
本帖中源码包是解压到/media/JDK6_build_area/jdk6u23目录中的。
为了解决一个缺少符号的问题,要在解压出来的源码目录里,找到j2se/src/solaris/native/sun/awt/awt_GraphicsEnv.c,第965行:
if (xerr->minor_code == X_ShmAttach) {
将X_ShmAttach改为1,变成:
if (xerr->minor_code == 1) {
设置环境变量
本帖描述的build过程中需要设置的环境变量只有一个,
引用
如果环境中已经设置了JAVA_HOME的话,要将该环境变量去掉,否做build过程中会有诡异的事情发生:
引用
检查编译环境的正确性
进入到解压后源码包的control/make目录中,用make dev-sanity命令即可。该命令后面要带上一些环境参数,完整如下
引用
$ make dev-sanity BUILD_DEPLOY=false SKIP_COMPARE_IMAGES=true ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ALT_DEVTOOLS_PATH=/usr/bin HOTSPOT_BUILD_JOBS=2
检查过程中输出的日志请见本帖附录。简单介绍其中几个参数的含义:
dev(或者DEV_ONLY):
把它设置为true可以让另外三个变量也变为true:SKIP_COMPARE_IMAGES、BUILD_INSTALL、NO_DOCS。
BUILD_DEPLOY:
把它设置为false可以避开javaws和浏览器Java插件之类的部分的build。
BUILD_INSTALL:
把它设置为false就不会build出安装包。因为安装包里有些奇怪的依赖,但即便不build出它也已经能得到完整的JDK映像,所以还是别build它好了。
SKIP_COMPARE_IMAGES:
比较本次build出来的映像与先前版本的差异。这个对我们来说没有意义,必须设置为false,否则sanity检查会报缺少先前版本JDK的映像。如果有设置dev或者DEV_ONLY=true的话这个不显式设置也行。
ALT_BOOTDIR:
Bootstrap JDK的安装路径。必须设置。
ALT_DEVTOOLS_PATH:
zip和unzip工具所在的路径。必须设置。
HOTSPOT_BUILD_JOBS:
这个变量主要是设置build HotSpot的过程的并发程度。基本上设到跟CPU的核数一样多没什么问题吧。这个参数不设也没关系。
ALT_JDK_IMPORT_PATH:
这个变量不用设置。因为要build的JDK足够完整,缺少的部分我们都不需要。
正式开始build
环境设置好之后,剩下就没啥问题了。在解压出来的源码包的control/make目录里连续执行两次下述命令即可。后一次时间会比较长,中间做点什么别的事吧,别傻等哦
引用
$ make dev BUILD_DEPLOY=false SKIP_COMPARE_IMAGES=true ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ALT_DEVTOOLS_PATH=/usr/bin HOTSPOT_BUILD_JOBS=2
为什么要连续执行两次呢?反正在本帖的环境里,源码包中所包含的Motif是没办法一次过顺利build出来的。第一执行上面的命令后,会看到类似这样的错误:
引用
gcc: /media/JDK6_build_area/jdk6u23/control/build/linux-i586/motif-i586/lib/libXm.a: No such file or directory
make[4]: *** [/media/JDK6_build_area/jdk6u23/control/build/linux-i586/lib/i386/motif21/libmawt.so] Error 1
make[4]: Leaving directory `/media/JDK6_build_area/jdk6u23/j2se/make/sun/motif21'
make[3]: *** [all] Error 1
make[3]: Leaving directory `/media/JDK6_build_area/jdk6u23/j2se/make/sun'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/media/JDK6_build_area/jdk6u23/j2se/make'
make[1]: *** [j2se-build] Error 2
make[1]: Leaving directory `/media/JDK6_build_area/jdk6u23/control/make'
make: *** [dev-build] Error 2
但其实没关系,无视它,再执行一次同样的命令,就build过去了。
Build正确完成后,最后应该可以看到类似下面的提示信息:
引用
generic_debug_build build finished: 11-01-16 03:11
make[2]: Leaving directory `/media/JDK6_build_area/jdk6u23/control/make'
Control workspace build finished: 11-01-16 03:11
make[1]: Leaving directory `/media/JDK6_build_area/jdk6u23/control/make'
然后到build出来的JDK映像的bin目录里去看看的话,
引用
rednaxelafx@vbox:/media/JDK6_build_area/jdk6u23/control/make$ cd ../build/linux-i586/j2sdk-image/bin/
rednaxelafx@vbox:/media/JDK6_build_area/jdk6u23/control/build/linux-i586/j2sdk-image/bin$ ./java -version
java version "1.6.0-internal"
Java(TM) SE Runtime Environment (build 1.6.0-internal-rednaxelafx_16_jan_2011_02_10-b00)
Java HotSpot(TM) Server VM (build 19.0-b09, mixed mode)
rednaxelafx@vbox:/media/JDK6_build_area/jdk6u23/control/build/linux-i586/j2sdk-image/bin$ cd ../../j2sdk-debug-image/fastdebug/bin/
rednaxelafx@vbox:/media/JDK6_build_area/jdk6u23/control/build/linux-i586/j2sdk-debug-image/fastdebug/bin$ ./java -version
java version "1.6.0-internal-fastdebug"
Java(TM) SE Runtime Environment (build 1.6.0-internal-fastdebug-rednaxelafx_16_jan_2011_02_38-b00)
Java HotSpot(TM) Server VM (build 19.0-b09-fastdebug, mixed mode)
到此,我们自己build出来的Sun(-> Oracle) JDK就到手了。然后随便改改代码、调试来玩玩吧
看,build出来的JDK里的JConsole运行也是正常的哦,前面libXm.a的那个错误不是大问题:
附录
make dev-sanity的命令及输出结果:(超出显示范围的部分请复制下来看吧)
引用
$ make dev-sanity BUILD_DEPLOY=false SKIP_COMPARE_IMAGES=true ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ALT_DEVTOOLS_PATH=/usr/bin HOTSPOT_BUILD_JOBS=2
cd ../../control/make
make sanity DEV_ONLY=true
make[1]: Entering directory `/media/JDK6_build_area/jdk6u23/control/make'
make[2]: Entering directory `/media/JDK6_build_area/jdk6u23/j2se/make'
make[2]: Leaving directory `/media/JDK6_build_area/jdk6u23/j2se/make'
Build Machine Information:
build machine =
Build Directory Structure:
CWD = /media/JDK6_build_area/jdk6u23/control/make
TOPDIR = ../..
CONTROL_TOPDIR = ../../control
HOTSPOT_TOPDIR = ../../hotspot
J2SE_TOPDIR = ../../j2se
MOTIF_TOPDIR = ../../motif
Build Directives:
BUILD_HOTSPOT = true
BUILD_MOTIF = true
BUILD_J2SE = true
BUILD_DEPLOY = false
BUILD_INSTALL = false
Hotspot Settings:
HOTSPOT_BUILD_JOBS = 2
HOTSPOT_OUTPUTDIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/outputdir
HOTSPOT_EXPORT_PATH = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/import
Bootstrap Settings:
BOOTDIR = /usr/lib/jvm/java-6-openjdk
ALT_BOOTDIR = /usr/lib/jvm/java-6-openjdk
BOOT_VER = 1.6 [requires at least 1.6]
MINIMUM_JDK_VERSION = 1.6.0
ALT_MINIMUM_JDK_VERSION =
OUTPUTDIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586
ALT_OUTPUTDIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586
ABS_OUTPUTDIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586
Build Tool Settings:
SLASH_JAVA = /java
ALT_SLASH_JAVA =
VARIANT = OPT
JDK_DEVTOOLS_DIR = /java/devtools
ALT_JDK_DEVTOOLS_DIR =
UNIXCOMMAND_PATH = /bin/
ALT_UNIXCOMMAND_PATH =
COMPILER_PATH = /usr/bin/
ALT_COMPILER_PATH =
DEVTOOLS_PATH = /usr/bin/
ALT_DEVTOOLS_PATH = /usr/bin
UNIXCCS_PATH = /usr/ccs/bin/
ALT_UNIXCCS_PATH =
USRBIN_PATH = /usr/bin/
ALT_USRBIN_PATH =
GCC29_COMPILER_PATH = /java/devtools/linux/gcc29/usr/
ALT_GCC29_COMPILER_PATH =
MOTIF_DIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/motif-i586
ALT_MOTIF_DIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/motif-i586
COMPILER_NAME = GCC
COMPILER_VERSION =
CC_VER = 4.4 [requires at least 3.2]
ZIP_VER = 3.0 [requires at least 2.2]
UNZIP_VER = 6.00 [requires at least 5.12]
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
TEMPDIR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/tmp
Build Directives:
USE_ONLY_BOOTDIR_TOOLS =
USE_HOTSPOT_INTERPRETER_MODE =
PEDANTIC =
DEV_ONLY = true
J2RE_ONLY =
NO_DOCS =
NO_IMAGES =
TOOLS_ONLY =
INSANE =
PARALLEL_COMPILES = true
PARALLEL_COMPILE_JOBS = 2
ALT_PARALLEL_COMPILE_JOBS =
FASTDEBUG =
COMPILER_WARNINGS_FATAL = false
COMPILER_WARNING_LEVEL =
INCREMENTAL_BUILD = false
CC_HIGHEST_OPT = -O3
CC_HIGHER_OPT = -O3
CC_LOWER_OPT = -O2
CXXFLAGS = -O2 -fPIC -DCC_NOEX -W -Wall -Wno-unused -Wno-parentheses
CFLAGS = -O2 -fno-strict-aliasing -fPIC -W -Wall -Wno-unused -Wno-parentheses
JAVA_BOOT = /usr/lib/jvm/java-6-openjdk/bin/java -client -Xmx512m -Xms256m
JAVAC_BOOT = /usr/lib/jvm/java-6-openjdk/bin/javac -J-XX:ThreadStackSize=768 -J-client -J-Xmx512m -J-Xms256m -J-Xbootclasspath/p:./../make/sun/javac/javac/gjc.jar -target 5
JAR_BOOT = /usr/lib/jvm/java-6-openjdk/bin/jar
JAVAH_BOOT = /usr/lib/jvm/java-6-openjdk/bin/javah -J-XX:ThreadStackSize=768 -J-client -J-Xmx512m -J-Xms256m -J-Xbootclasspath/p:./../make/sun/javac/javac/gjc.jar
JAVA = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/bin/java -client -Xmx512m -Xms256m
JAVAC = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/bin/javac -J-XX:ThreadStackSize=768 -J-client -J-Xmx512m -J-Xms256m
JAR = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/bin/jar
JAVAH =
Build Platform Settings:
USER = rednaxelafx
PLATFORM = linux
ARCH = i586
LIBARCH = i386
ARCH_FAMILY = i586
ARCH_DATA_MODEL = 32
ARCHPROP = i386
LINUX_VERSION = Unknown linux
ALSA_VERSION = 1.0.23
OS_VERSION = 2.6.35-24-generic [requires at least 2.4.9-e.3]
OS_NAME = linux
TEMP_FREE_SPACE = 3056880
FREE_SPACE = 4614720
MB_OF_MEMORY = 2012
GNU Make Settings:
MAKE = make
MAKE_VER = 3.81 [requires at least 3.78]
MAKECMDGOALS = sanity
MAKEFLAGS = w -- ARCH_DATA_MODEL=32 ALT_MOTIF_DIR=/media/JDK6_build_area/jdk6u23/control/build/linux-i586/motif-i586 BUILD_MOTIF=true BUILD_HOTSPOT=true ALT_HOTSPOT_IMPORT_PATH=/media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/import ALT_OUTPUTDIR=/media/JDK6_build_area/jdk6u23/control/build/linux-i586 FULL_VERSION=1.6.0-internal-rednaxelafx_16_jan_2011_21_45-b00 JDK_BUILD_NUMBER=b00 BUILD_NUMBER=b00 MILESTONE=internal EXTERNALSANITYCONTROL=true HOTSPOT_IMPORT_CHECK=false HOTSPOT_BUILD_JOBS=2 ALT_DEVTOOLS_PATH=/usr/bin ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk SKIP_COMPARE_IMAGES=true BUILD_DEPLOY=false DEV_ONLY=true
SHELL = /bin/sh
Target Build Versions:
JDK_VERSION = 1.6.0
MILESTONE = internal
RELEASE = 1.6.0-internal
FULL_VERSION = 1.6.0-internal-rednaxelafx_16_jan_2011_21_45-b00
BUILD_NUMBER = b00
External File/Binary Locations:
USRJDKINSTANCES_PATH = /opt/java
JDK_IMPORT_PATH = /java/re/j2se/1.6.0/promoted/latest/binaries/linux-i586
ALT_JDK_IMPORT_PATH =
HOTSPOT_DOCS_IMPORT_PATH = /NO_DOCS_DIR
ALT_HOTSPOT_DOCS_IMPORT_PATH =
HOTSPOT_IMPORT_PATH = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/import
ALT_HOTSPOT_IMPORT_PATH = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/import
HOTSPOT_CLIENT_PATH = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/import/jre/lib/i386/client
ALT_HOTSPOT_CLIENT_PATH =
HOTSPOT_SERVER_PATH = /media/JDK6_build_area/jdk6u23/control/build/linux-i586/hotspot/import/jre/lib/i386/server
ALT_HOTSPOT_SERVER_PATH =
CACERTS_FILE = ./../src/share/lib/security/cacerts
ALT_CACERTS_FILE =
MOZILLA_HEADERS_PATH = /java/devtools/share/plugin
ALT_MOZILLA_HEADERS_PATH =
CUPS_HEADERS_PATH = /usr/include
ALT_CUPS_HEADERS_PATH =
Previous JDK Settings:
PREVIOUS_RELEASE_PATH = /java/re/j2se/1.5.0/archive/fcs/bundles/linux-i586
ALT_PREVIOUS_RELEASE_PATH =
PREVIOUS_JDK_VERSION = 1.5.0
ALT_PREVIOUS_JDK_VERSION =
PREVIOUS_JDK_FILE = jdk-1_5_0-linux-i586.tar.gz
ALT_PREVIOUS_JDK_FILE =
PREVIOUS_JRE_FILE = jdk-1_5_0-linux-i586.tar.gz
ALT_PREVIOUS_JRE_FILE =
WARNING: Your are not building DEPLOY workspace from
the control build. This will result in a development-only
build of the J2SE workspace, lacking the plugin and javaws binaries.
WARNING: Your are not building INSTALL workspace from
the control build. This will result in a development-only
build of the J2SE workspace, lacking the installation bundles
WARNING: Your build environment has the variable DEV_ONLY
defined. This will result in a development-only
build of the J2SE workspace, lacking the documentation
build and installation bundles.
WARNING: The official linux builds use OS version 2.4.9-e.3.
You appear to be using OS version 2.6.35-24-generic.
WARNING: The build is being done on Linux Unknown linux.
The official linux builds use Linux Advanced Server,
specifically Linux Advanced Server release 2.1AS.
The version found was '2.6.35-24-generic'.
WARNING: The directory HOTSPOT_DOCS_IMPORT_PATH=/NO_DOCS_DIR
does not exist, check your value of ALT_HOTSPOT_DOCS_IMPORT_PATH.
WARNING: The linux compiler must be version 3.2
Specifically the GCC compiler.
You appear to be using compiler version: 4.4
The compiler was obtained from the following location:
/usr/bin/
Please change your compiler.
WARNING: Importing CUPS from a system location
Sanity check passed.
make[1]: Leaving directory `/media/JDK6_build_area/jdk6u23/control/make'
apt-get install过的包及其传递依赖:
引用
$ sudo apt-get install openjdk-6-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libice-dev libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev
libxau-dev libxcb1-dev libxdmcp-dev libxt-dev x11proto-core-dev
x11proto-input-dev x11proto-kb-dev xtrans-dev
Suggested packages:
openjdk-6-demo openjdk-6-source visualvm
The following NEW packages will be installed:
libice-dev libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev
libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-6-jdk
x11proto-core-dev x11proto-input-dev x11proto-kb-dev xtrans-dev
0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.3MB of archives.
After this operation, 44.3MB of additional disk space will be used.
引用
$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
dpkg-dev fakeroot g++ g++-4.4 libalgorithm-diff-perl libalgorithm-merge-perl
libdpkg-perl libstdc++6-4.4-dev patch
Suggested packages:
debian-keyring g++-multilib g++-4.4-multilib gcc-4.4-doc libstdc++6-4.4-dbg
libstdc++6-4.4-doc diffutils-doc
The following NEW packages will be installed:
build-essential dpkg-dev fakeroot g++ g++-4.4 libalgorithm-diff-perl
libalgorithm-merge-perl libdpkg-perl libstdc++6-4.4-dev patch
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,319kB of archives.
After this operation, 25.0MB of additional disk space will be used.
引用
$ sudo apt-get install libasound2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
libasound2-doc
The following NEW packages will be installed:
libasound2-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 509kB of archives.
After this operation, 1,876kB of additional disk space will be used.
引用
$ sudo apt-get install libcups2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
comerr-dev krb5-multidev libgcrypt11-dev libgnutls-dev libgpg-error-dev
libgssrpc4 libkadm5clnt-mit7 libkadm5srv-mit7 libkdb5-4 libkrb5-dev
libtasn1-3-dev zlib1g-dev
Suggested packages:
krb5-doc libgcrypt11-doc gnutls-doc gnutls-bin guile-gnutls krb5-user
The following NEW packages will be installed:
comerr-dev krb5-multidev libcups2-dev libgcrypt11-dev libgnutls-dev
libgpg-error-dev libgssrpc4 libkadm5clnt-mit7 libkadm5srv-mit7 libkdb5-4
libkrb5-dev libtasn1-3-dev zlib1g-dev
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,968kB of archives.
After this operation, 6,136kB of additional disk space will be used.
引用
$ sudo apt-get install gawk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
gawk
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 530kB of archives.
After this operation, 2,150kB of additional disk space will be used.
引用
$ sudo apt-get install libmotif-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libmotif3
The following NEW packages will be installed:
libmotif-dev libmotif3
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,143kB of archives.
After this operation, 12.1MB of additional disk space will be used.
引用
$ sudo apt-get install libxrender-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
x11proto-render-dev
The following NEW packages will be installed:
libxrender-dev x11proto-render-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 44.1kB of archives.
After this operation, 217kB of additional disk space will be used.
引用
$ sudo apt-get install xorg-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libdmx-dev libdmx1 libexpat1-dev libfontconfig1-dev libfontenc-dev
libfreetype6-dev libfs-dev libpciaccess-dev libpixman-1-dev libxaw7-dev
libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev
libxfont-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev
libxmu-headers libxmuu-dev libxpm-dev libxrandr-dev libxres-dev libxss-dev
libxtst-dev libxv-dev libxvmc-dev libxxf86dga-dev libxxf86vm-dev
x11proto-bigreqs-dev x11proto-composite-dev x11proto-damage-dev
x11proto-dmx-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-fonts-dev
x11proto-gl-dev x11proto-randr-dev x11proto-record-dev x11proto-resource-dev
x11proto-scrnsaver-dev x11proto-video-dev x11proto-xcmisc-dev
x11proto-xext-dev x11proto-xf86bigfont-dev x11proto-xf86dga-dev
x11proto-xf86dri-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev
xserver-xorg-dev
The following NEW packages will be installed:
libdmx-dev libdmx1 libexpat1-dev libfontconfig1-dev libfontenc-dev
libfreetype6-dev libfs-dev libpciaccess-dev libpixman-1-dev libxaw7-dev
libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev
libxfont-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev
libxmu-headers libxmuu-dev libxpm-dev libxrandr-dev libxres-dev libxss-dev
libxtst-dev libxv-dev libxvmc-dev libxxf86dga-dev libxxf86vm-dev
x11proto-bigreqs-dev x11proto-composite-dev x11proto-damage-dev
x11proto-dmx-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-fonts-dev
x11proto-gl-dev x11proto-randr-dev x11proto-record-dev x11proto-resource-dev
x11proto-scrnsaver-dev x11proto-video-dev x11proto-xcmisc-dev
x11proto-xext-dev x11proto-xf86bigfont-dev x11proto-xf86dga-dev
x11proto-xf86dri-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xorg-dev
xserver-xorg-dev
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,389kB of archives.
After this operation, 17.0MB of additional disk space will be used.
引用
$ sudo apt-get install m4
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
m4
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 276kB of archives.
After this operation, 655kB of additional disk space will be used.
引用
$ sudo apt-get install x11proto-print-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
x11proto-print-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.3kB of archives.
After this operation, 98.3kB of additional disk space will be used.
引用
$ sudo apt-get install xprint
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libaudit0 libxfontp1 libxprintapputil1 libxprintutil1 xbase-clients
xprint-common xprint-utils
The following NEW packages will be installed:
libaudit0 libxfontp1 libxprintapputil1 libxprintutil1 xbase-clients xprint
xprint-common xprint-utils
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,787kB of archives.
After this operation, 4,633kB of additional disk space will be used.
引用
$ sudo apt-get install xutils-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
xutils-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 314kB of archives.
After this operation, 1,765kB of additional disk space will be used.
====================================================================
2011-08-07追记
刚build了一个最新的hotspot-comp出来,顺便加到这帖里。
源码地址:
要先装上Mercurial来抓源码。然后build之前要确定装了Ant。
下好源码后
chmod +x get_source.sh
./get_source.sh
make LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ALT_DEVTOOLS_PATH=/usr/bin SKIP_FASTDEBUG_BUILD=false HOTSPOT_BUILD_JOBS=2
如果jaxp和jaxwa的build出错的话在它们各自的build.properties文件里加上allow.downloads=true
jdk目录build的时候在javadoc上出了点问题,所以把jdk/make/Makefile里的docs整个注释掉了
64-bit: ARCH_DATA_MODEL=64
Charles Nutter's build script: https://gist.github.com/1148321
https://blogs.oracle.com/kto/entry/faster_openjdk_build_tricks
make -C make ALT_BOOTDIR=~/sdk/jdk1.8.0b49 ALT_SLASH_JAVA=$HOME/java LANG=C HOTSPOT_BUILD_JOBS=4 ARCH_DATA_MODEL=64 all_fastdebug
make sure this symlink is live: ~/java/re/j2se/1.8.0/promoted/latest/binaries/linux-amd64 -> some valid JDK8 installation
$ ln -s -T ~/sdk/jdk1.8.0 linux-amd64
在64位Ubuntu上构建32位HotSpot VM的话,
ARCH_DATA_MODEL=32
可能需要额外装 ia32-libs libc6-dev-i386 lib32stdc++6 g++-multilib 等