操作系统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