昨晚复习了一下深入JVM虚拟机,下午想着把代码拉下来自己编译一下把。
发现已经有人做过类似的事情了,权当给自己做个笔记把。
本机环境是(就是编译android6.0的官方推荐环境了) ubuntu14
, openjdk7
参考了:
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 @ 2017年 08月 19日 星期六 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'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。