事象
OpenJDK7u40 をビルドすると "./gamma: relocation error: .../libjava.so: symbol JVM_FindClassFromCaller, version SUNWprivate_1.1 not defined in file libjvm.so with link time" というエラーで失敗する。
$ hg clone http://hg.openjdk.java.net/jdk7u/jdk7u40 jdk7u40 $ cd jdk7u40 $ sh ./get_source.sh $ unset JAVA_HOME $ unset LD_LIBRARY_PATH $ export LANG=C $ export ALT_BOOTDIR=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64 $ export ALLOW_DOWNLOADS=true $ export EXTRA_LIBS=/usr/lib/libasound.so.2 $ export ANT_HOME=/usr/local/bin/apache-ant-1.7.1 $ export PATH=$PATH:/usr/local/bin/apache-ant-1.7.1/bin $ make sanity $ make (中略) echo "**NOTICE** Dtrace support disabled: "/usr/include/sys/sdt.h not found"" **NOTICE** Dtrace support disabled: /usr/include/sys/sdt.h not found make[6]: Leaving directory `/home/yazekats/Documents/mercurial/jdk7u40/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product' All done. make[5]: Leaving directory `/home/yazekats/Documents/mercurial/jdk7u40/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product' cd linux_amd64_compiler2/product && ./test_gamma Using java runtime at: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64/jre ./gamma: relocation error: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.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[4]: *** [product] Error 127 make[4]: Leaving directory `/home/yazekats/Documents/mercurial/jdk7u40/build/linux-amd64/hotspot/outputdir' make[3]: *** [generic_build2] Error 2 make[3]: Leaving directory `/home/yazekats/Documents/mercurial/jdk7u40/hotspot/make' make[2]: *** [product] Error 2 make[2]: Leaving directory `/home/yazekats/Documents/mercurial/jdk7u40/hotspot/make' make[1]: *** [hotspot-build] Error 2 make[1]: Leaving directory `/home/yazekats/Documents/mercurial/jdk7u40' make: *** [build_product_image] Error 2
原因
- OpenJDK 7 をビルドする際は ALT_BOOTDIR に JDK6u45 を指定する必要がある。
Download and install Oracle JDK 1.6.0_45 and set it to "ALT_BOOTDIR" and "ALT_JDK_IMPORT_PATH", please do not use OpenJDK1.6
java - Cannot compile openjdk7 source code on CentOS6.5 - Stack Overflow
Right now test_gamma runs with the boot JDK which is JDK n-1 (where JDK n is the version we are actually compiling for). This setup is unsupported and thus should not be done during HotSpot builds.
[JDK-8006965] remove test_gamma and add dedicated test_* targets instead - Java Bug System
対策
OpenJDK6u45 をインストールして環境変数 ALT_BOOTDIR にパスをセットしてからビルドする。
- Java Archive Downloads - Java SE 6 で [Java SE Development Kit 6u45] をクリックし、"Java SE 6 Downloads" に移動する。
- jdk-6u45-linux-x64.bin をダウンロードする。
- OpenJDK6u45 をインストールする。
$ chmod +x jdk-6u45-linux-x64.bin $ ./jdk-6u45-linux-x64.bin
- OpenJDK7u40 をビルドする(ALT_BOOTDIR 以外の環境変数は上記と同じものを使う)
$ export ALT_BOOTDIR=/home/yazekats/Downloads/bin/jdk1.6.0_45 $ make