OpenJDKをビルドしてみた
環境はMac。
基本ソースをMercurialでクローンしてREADME読めばできる。
READMEにもあるけど、詳しいビルド方法はここを参照すればいい。
http://hg.openjdk.java.net/jdk8/jdk8/raw-file/tip/README-builds.html
以下、作業手順。
デバッグ版が欲しい場合は Configure時に--enable-debug するとよい。
% hg clone http://hg.openjdk.java.net/jdk8/jdk8 jdk8_src requesting all changes adding changesets adding manifests adding file changes added 942 changesets with 1309 changes to 136 files updating to branch default 82 files updated, 0 files merged, 0 files removed, 0 files unresolved % cd jdk8_src % ./get_source.sh # Repositories: corba jaxp jaxws langtools jdk hotspot nashorn corba: hg clone http://hg.openjdk.java.net/jdk8/jdk8/corba corba jaxp: hg clone http://hg.openjdk.java.net/jdk8/jdk8/jaxp jaxp jaxp: requesting all changes corba: requesting all changes corba: adding changesets jaxp: adding changesets Waiting 5 secs before spawning next background command. jaxp: adding manifests corba: adding manifests jaxws: hg clone http://hg.openjdk.java.net/jdk8/jdk8/jaxws jaxws langtools: hg clone http://hg.openjdk.java.net/jdk8/jdk8/langtools langtools jaxws: requesting all changes langtools: requesting all changes jaxws: adding changesets langtools: adding changesets 〜 中略 〜 .: cd . && hg pull -u ./corba: cd ./corba && hg pull -u ./hotspot: cd ./hotspot && hg pull -u ./jaxp: cd ./jaxp && hg pull -u ./jaxws: cd ./jaxws && hg pull -u ./jdk: cd ./jdk && hg pull -u ./langtools: cd ./langtools && hg pull -u ./nashorn: cd ./nashorn && hg pull -u ./hotspot: pulling from http://hg.openjdk.java.net/jdk8/jdk8/hotspot ./nashorn: pulling from http://hg.openjdk.java.net/jdk8/jdk8/nashorn ./jaxws: pulling from http://hg.openjdk.java.net/jdk8/jdk8/jaxws ./jaxp: pulling from http://hg.openjdk.java.net/jdk8/jdk8/jaxp ./langtools: pulling from http://hg.openjdk.java.net/jdk8/jdk8/langtools .: pulling from http://hg.openjdk.java.net/jdk8/jdk8 ./corba: pulling from http://hg.openjdk.java.net/jdk8/jdk8/corba ./jdk: pulling from http://hg.openjdk.java.net/jdk8/jdk8/jdk ./hotspot: searching for changes ./hotspot: no changes found ./jaxws: searching for changes ./jaxws: no changes found ./jaxp: searching for changes ./jaxp: no changes found ./nashorn: searching for changes ./nashorn: no changes found ./langtools: searching for changes ./langtools: no changes found ./corba: searching for changes ./corba: no changes found .: searching for changes .: no changes found ./jdk: searching for changes ./jdk: no changes found % bash ./configure --enable-debug --with-target-bits=64 Running generated-configure.sh configure: Configuration created at Sat Oct 4 01:07:52 JST 2014. configure: configure script generated at timestamp 1389186094. checking for basename... /usr/bin/basename checking for bash... /bin/bash checking for cat... /bin/cat checking for chmod... /bin/chmod checking for cmp... /usr/bin/cmp 〜 中略 〜 checking if build directory is on local disk... yes configure: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/config.status config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/spec.gmk config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/hotspot-spec.gmk config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/bootcycle-spec.gmk config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/compare.sh config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/spec.sh config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/Makefile config.status: creating /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug/config.h ==================================================== A new configuration has been successfully created in /Users/plugram/Desktop/jvm/jdk8_src/build/macosx-x86_64-normal-server-fastdebug using configure arguments '--enable-debug --with-target-bits=64'. Configuration summary: * Debug level: fastdebug * JDK variant: normal * JVM variants: server * OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64 Tools summary: * Boot JDK: java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) (at /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home) * C Compiler: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build) version 2335.15.00) (at /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2) * C++ Compiler: i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build) version 2335.15.00) (at /usr/llvm-gcc-4.2/bin/llvm-g++-4.2) Build performance summary: * Cores to use: 2 * Memory limit: 4096 MB * ccache status: not installed (consider installing) Build performance tip: ccache gives a tremendous speedup for C++ recompilations. You do not have ccache installed. Try installing it. % make all Building OpenJDK for target 'all' in configuration 'macosx-x86_64-normal-server-fastdebug' ## Starting langtools Compiling 2 files for BUILD_TOOLS Compiling 31 properties into resource bundles Compiling 777 files for BUILD_BOOTSTRAP_LANGTOOLS Creating langtools/dist/bootstrap/lib/javac.jar Updating langtools/dist/lib/src.zip Compiling 780 files for BUILD_FULL_JAVAC Creating langtools/dist/lib/classes.jar ## Finished langtools (build time 00:01:02) ## Starting hotspot make[2]: warning: -jN forced in submake: disabling jobserver mode. INFO: ENABLE_FULL_DEBUG_SYMBOLS=1 INFO: ENABLE_FULL_DEBUG_SYMBOLS=1 INFO: ENABLE_FULL_DEBUG_SYMBOLS=1 INFO: ENABLE_FULL_DEBUG_SYMBOLS=1 INFO: ENABLE_FULL_DEBUG_SYMBOLS=1 Creating Makefile ... Creating directory list ../shared_dirs.lst Creating flags.make ... Creating flags_vm.make ... Creating vm.make ... Creating adlc.make ... Creating jvmti.make ... Creating trace.make ... Creating sa.make ... Creating dtrace.make ... INFO: ENABLE_FULL_DEBUG_SYMBOLS=1 Creating Makefile ... Creating flags.make ... Creating flags_vm.make ... Creating vm.make ... Creating adlc.make ... Creating jvmti.make ... Creating trace.make ... 〜 中略 〜 ## Finished docs (build time 00:03:48) ----- Build times ------- Start 2014-10-04 01:10:54 End 2014-10-04 01:39:25 00:00:50 corba 00:01:00 demos 00:03:48 docs 00:12:07 hotspot 00:01:27 images 00:00:30 jaxp 00:00:44 jaxws 00:06:44 jdk 00:01:02 langtools 00:00:18 nashorn 00:28:31 TOTAL ------------------------- Finished building OpenJDK for target 'all' % make install Building OpenJDK for target 'install' in configuration 'macosx-x86_64-normal-server-fastdebug' ## Starting langtools ## Finished langtools (build time 00:00:01) ## Starting hotspot ## Finished hotspot (build time 00:00:00) ## Starting corba ## Finished corba (build time 00:00:00) ## Starting jaxp ## Finished jaxp (build time 00:00:01) ## Starting jaxws ## Finished jaxws (build time 00:00:00) ## Starting jdk ## Finished jdk (build time 00:00:03) ## Starting demos ## Finished demos (build time 00:00:00) ## Starting nashorn ## Finished nashorn (build time 00:00:00) ## Starting images Copying images/j2re-bundle/jre1.8.0.jre/Contents/Home/release Copying images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/.DS_Store Copying images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/jre Copying images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/jre/.DS_Store Copying images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/release ## Finished images (build time 00:00:04) ## Starting install Installing jdk image into /usr/local/jvm/openjdk-1.8.0-internal-fastdebug and creating 40 links from /usr/local/bin into the jdk. ## Finished install (build time 00:00:04) ----- Build times ------- Start 2014-10-04 01:54:51 End 2014-10-04 01:55:04 00:00:00 corba 00:00:00 demos 00:00:00 hotspot 00:00:04 images 00:00:04 install 00:00:01 jaxp 00:00:00 jaxws 00:00:03 jdk 00:00:01 langtools 00:00:00 nashorn 00:00:13 TOTAL -------------------------
インストールしたら /usr/local/bin に入った。
さっそく実験。
以下のようなソースを書いて実行。
class Hello { public static void main(String[] args) { new Hello().hello(); } public int hello() { int result = 1 + 2; return result; } }
% /usr/local/bin/javac Hello.java % /usr/local/bin/java -client -Xcomp -XX:+PrintIRWithLIR -XX:CompileOnly="Hello.hello" Hello __bci__use__tid____instr____________________________________ . 0 0 4 B1 [0, 0] -> B2 sux: B2 label [label:0xec065838] . 0 0 7 std entry B2 std_entry move [rsi|L] [R177|L] move [metadata:0xa1684420|M] [R178|M] move [Base:[R178|M] Disp: 108|I] [R179|I] add [R179|I] [int:8|I] [R179|I] move [R179|I] [Base:[R178|M] Disp: 108|I] move [metadata:0xa16842f0|M] [R180|M] logic_and [R179|I] [int:0|I] [R179|I] cmp [R179|I] [int:0|I] branch [EQ] [CounterOverflowStub: 0xec067718] label [label:0xec067740] branch [AL] [B2] __bci__use__tid____instr____________________________________ . 0 0 5 B2 (S) [0, 0] -> B0 dom B1 sux: B0 pred: B1 label [label:0xec065b48] . 0 0 6 goto B0 branch [AL] [B0] __bci__use__tid____instr____________________________________ . 0 0 0 B0 (SV) [0, 3] dom B2 pred: B2 label [label:0xec064e38] . 3 0 i3 ireturn i2 move [int:3|I] [rax|I] return [rax|I] __bci__use__tid____instr____________________________________ . 0 0 4 B1 [0, 0] -> B0 sux: B0 label [label:0xec8a8a38] . 0 0 5 std entry B0 std_entry move [rsi|L] [R177|L] branch [AL] [B0] __bci__use__tid____instr____________________________________ . 0 0 0 B0 (SV) [0, 3] dom B1 pred: B1 label [label:0xec8a8038] . 3 0 i3 ireturn i2 move [int:3|I] [rax|I] return [rax|I]
とりあえず今日はここまで。