ubuntu14 编译 openjdk7

前端之家收集整理的这篇文章主要介绍了ubuntu14 编译 openjdk7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

昨晚复习了一下深入JVM虚拟机,下午想着把代码拉下来自己编译一下把。
发现已经有人做过类似的事情了,权当给自己做个笔记把。

本机环境是(就是编译android6.0的官方推荐环境了) ubuntu14openjdk7

参考了:

https://ayonel.me/index.php/2017/01/05/compile_openjdk/

sudo apt-get install build-essential \ 
ant libxrender-dev xorg-dev libasound2-dev \
libcups2-dev gawk zip libxtst-dev libxi-dev \
libxt-dev

git clone https://github.com/dmlloyd/openjdk.git

cd openjdk
git checkout origin/jdk7u/jdk7u
git checkout jdk7u/jdk7u

mkdir out
vim build.sh

build.sh

export LANG=C
export ALT_BOOTDIR=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export ALT_JDK_IMPORT_PATH=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export ALLOW_DOWNLOADS=true
export USE_PRECOMPILED_HEADER=true
export BUILD_LANGTOOLS=true
export BUILD_JAXP=false
export BUILD_JAXWS=false
export BUILD_CORBA=false
export BUILD_HOTSPOT=true
export BUILD_JDK=true
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export DEBUG_NAME=debug
BUILD_DEPLOY=false
BUILD_INSTALL=false
export ALT_OUTPUTDIR=/home/yeshen/Documents/ys/openjdk/out
unset CLASSPATH
unset JAVA_HOME
make sanity
DEBUG_BINARIES=true make 2>&1 | tee $ALT_OUTPUTDIR/build.log
chmod +x build.sh
./build.sh

测试

cd out/j2sdk-image/bin
./java -version

openjdk version "1.7.0-internal-debug"
OpenJDK Runtime Environment (build 1.7.0-internal-debug-yeshen_2017_08_19_20_05-b00)
OpenJDK 64-Bit Server VM (build 24.95-b00-jvmg,mixed mode)

中间遇到一点问题

echo "**NOTICE** Dtrace support disabled: "/usr/include/sys/sdt.h not found""
**NOTICE** Dtrace support disabled: /usr/include/sys/sdt.h not found
make[7]: Leaving directory `/home/yeshen/Documents/ys/openjdkout-debug/hotspot/outputdir/linux_amd64_compiler2/jvmg' All done. make[6]: Leaving directory `/home/yeshen/Documents/ys/openjdkout-debug/hotspot/outputdir/linux_amd64_compiler2/jvmg'
cd linux_amd64_compiler2/jvmg && ./test_gamma
Error occurred during initialization of VM
Using java runtime at: /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre
java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:514)
    at java.lang.System.initProperties(Native Method)
    at java.lang.System.initializeSystemClass(System.java:1119)

make[5]: *** [jvmg] Error 1
make[5]: Leaving directory `/home/yeshen/Documents/ys/openjdkout-debug/hotspot/outputdir' make[4]: *** [generic_build2] Error 2 make[4]: Leaving directory `/home/yeshen/Documents/ys/openjdk/hotspot/make'
make[3]: *** [jvmg] Error 2
make[3]: Leaving directory `/home/yeshen/Documents/ys/openjdk/hotspot/make' make[2]: *** [hotspot-build] Error 2 make[2]: Leaving directory `/home/yeshen/Documents/ys/openjdk'
make[1]: *** [generic_debug_build] Error 2
make[1]: Leaving directory `/home/yeshen/Documents/ys/openjdk' make: *** [build_debug_image] Error 2

根据网上的提示做了修改

diff --git a/hotspot/make/linux/Makefile b/hotspot/make/linux/Makefile
index 99e8c37..4c1dcaa 100644
--- a/hotspot/make/linux/Makefile
+++ b/hotspot/make/linux/Makefile
@@ -288,42 +288,42 @@ platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in

 $(TARGETS_C2):  $(SUBDIRS_C2)
        cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
-       cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && ./test_gamma
+       cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ 
 ifdef INSTALL
        cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
 endif

 $(TARGETS_TIERED):  $(SUBDIRS_TIERED)
        cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
-       cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,$@) && ./test_gamma
+       cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,$@) 
 ifdef INSTALL
        cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,$@) && $(MAKE) $(MFLAGS) install
 endif

 $(TARGETS_C1):  $(SUBDIRS_C1)
        cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,$@) && $(MAKE) $(MFLAGS)
-       cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,$@) && ./test_gamma
+       cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,$@)
 ifdef INSTALL
        cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,$@) && $(MAKE) $(MFLAGS) install
 endif

 $(TARGETS_CORE):  $(SUBDIRS_CORE)
        cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,$@) && $(MAKE) $(MFLAGS)
-       cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,$@) && ./test_gamma
+       cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,$@) 
 ifdef INSTALL
        cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,$@) && $(MAKE) $(MFLAGS) install
 endif

 $(TARGETS_ZERO):  $(SUBDIRS_ZERO)
        cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,$@) && $(MAKE) $(MFLAGS)
-       cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,$@) && ./test_gamma
+       cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,$@) 
 ifdef INSTALL
        cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,$@) && $(MAKE) $(MFLAGS) install
 endif

 $(TARGETS_SHARK):  $(SUBDIRS_SHARK)
        cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,$@) && $(MAKE) $(MFLAGS)
-       cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,$@) && ./test_gamma
+       cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,$@) 
 ifdef INSTALL
        cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,$@) && $(MAKE) $(MFLAGS) install
 endif
>>>Finished making images @ 20170819日 星期六 20:17:10 CST ...
make[2]: Leaving directory `/home/yeshen/Documents/ys/openjdk/jdk/make' ######################################################################## ##### Leaving jdk for target(s) sanity all images ##### ######################################################################## ##### Build time 00:04:00 jdk for target(s) sanity all images ##### ######################################################################## #-- Build times ---------- Target debug_build Start 2017-08-19 20:09:10 End 2017-08-19 20:17:10 00:03:41 hotspot 00:04:00 jdk 00:00:19 langtools 00:08:00 TOTAL ------------------------- make[1]: Leaving directory `/home/yeshen/Documents/ys/openjdk'

猜你在找的Ubuntu相关文章