JDK6をソースコードからビルド

jvmgcまわりの挙動を確認する為、CentOS上でJDK6のソースコードを取得してビルドしてみました。基本的な流れは以下のページを参考にしています。

「Compile Hotspot JDK from Source Code」
http://konpairu.net/blog/archives/139

ビルドするのに色々躓きましたが、その度ググって何とかなりました。躓いた箇所と対応を、備忘録として記載しておきます。

依存パッケージのインストール

# yum install alsa-lib-devel -y
# yum install cups-devel -y

Missing ./../src/share/lib/fonts/LucidaTypewriterRegular.ttf

ERROR: Missing ./../src/share/lib/fonts/LucidaTypewriterRegular.ttf. Verify you have downloaded and overlayed on the source area all the binary files.

フォントのコピーが必要。以下のページを参考にしました。

Java SE 6(Mustang)をソースからビルドする」
http://d.hatena.ne.jp/torutk/20050825/1124985836

# cp -pir /opt/jdk1.6.0_16/jre/lib/fonts/* ../../j2se/src/share/lib/fonts/

No rule to make target `/usr/X11R6/lib/X11/config/Imake.tmpl'

make[3]: *** No rule to make target `/usr/X11R6/lib/X11/config/Imake.tmpl', needed by `xmkmf'. Stop.

X11のフォルダ構成の問題らしい。別の所にあるファイルだったのでsymlinkを貼りました。

# cd /usr/X11R6/lib/
# ls -l X11
(何も無かった)
# rm -r X11
# ln -s /usr/share/X11 X11

error: static declaration of 'sigignore' follows non-static declaration

../../../../src/solaris/hpi/native_threads/src/interrupt_md.c:115: error: static declaration of 'sigignore' follows non-static declaration
/usr/include/signal.h:377: error: previous declaration of 'sigignore' was here

ヘッダではnon-staticで宣言されているものの、実装ではstaticになっていることが原因。
以下のページを参考にしました。

「jdk1.6のコンパイル
http://www.melange.co.jp/blog/?p=779

# pushd ../../j2se/src/solaris/hpi/native_threads/src/
# cp -pi interrupt_md.c interrupt_md.org
# vi interrupt_md.c
# diff -u interrupt_md.org interrupt_md.c
--- interrupt_md.org    2012-02-27 18:26:56.000000000 +0900
+++ interrupt_md.c      2012-03-03 20:09:06.000000000 +0900
@@ -110,7 +110,7 @@
 }
 
 #ifndef HAVE_SIGIGNORE
-static int                                                     
+int                                                    
 sigignore(int sig)             
 {                              
     struct sigaction action;
# popd

No rule to make target `/usr/src/jvms/jdk16u16/control/build/linux-amd64/classes/com/sun/java/swing/plaf/windows/icons/Computer.gif'

make[5]: *** No rule to make target `/usr/src/jvms/jdk16u16/control/build/linux-amd64/classes/com/sun/java/swing/plaf/windows/icons/Computer.gif', needed by `other_files'. Stop.

Computer.gif等の画像ファイルをコピーして取り込もうとしているようです。この画像を探してみたのですが、bootstrap jdkに含まれてなかった為、コピーするタスク自体を消しました。

# pushd ../../j2se/make/javax/swing/plaf
# cp -pi FILES.gmk FILES.org
# vi FILES.gmk 
# popd

No rule to make target `/usr/src/jvms/jdk16u16/control/build/linux-amd64/lib/audio/soundbank.gm'

make[4]: *** No rule to make target `/usr/src/jvms/jdk16u16/control/build/linux-amd64/lib/audio/soundbank.gm', needed by `copy-files'. Stop.
soundbank.gmはbootstrap jdkjre/libの下にあったので、それをコピーして先に進めました。

# cp -pi /home/masayuki/install/soundbank.gm ../build/linux-amd64/lib/audio/

(諸事情によりコピー元のパスがjre/libではありませんが)

../../../src/solaris/native/sun/awt/img_util_md.h:14: error: expected specifier-qualifier-list before 'XID'

../../../src/solaris/native/sun/awt/img_util_md.h:14: error: expected specifier-qualifier-list before 'XID'

以下のページを参考にして、libXt-develをインストール。

「Building OpenJDK on Ubuntu
http://d.hatena.ne.jp/dolduke/20080420

yum install libXt-devel -y

/usr/bin/ld: cannot find -lXext

/usr/bin/ld: cannot find -lXext

libXext-develをインストール。

# yum install libXext-devel -y

/usr/bin/ld: cannot find -lXtst

/usr/bin/ld: cannot find -lXtst

libXtst-develをインストール。

# yum install libXtst-devel -y

../../../src/solaris/native/sun/awt/awt_dnd.c:172: error: static declaration of 'xerror_code' follows non-static declaration

../../../src/solaris/native/sun/awt/awt_dnd.c:172: error: static declaration of 'xerror_code' follows non-static declaration

awt_dnd.cのxerror_codeのstaticを外しました。

# pushd ../../j2se/src/solaris/native/sun/awt/
# cp -pi awt_dnd.c awt_dnd.org
# vi awt_dnd.c
# diff -u awt_dnd.org awt_dnd.c
--- awt_dnd.org 2012-02-27 18:26:56.000000000 +0900
+++ awt_dnd.c   2012-03-03 21:24:11.000000000 +0900
@@ -169,7 +169,7 @@
     return awt_root_window;
 }
 
-static unsigned char xerror_code = Success;
+unsigned char xerror_code = Success;
 
 static int 
 xerror_handler(Display *dpy, XErrorEvent *err) {
# popd

No rule to make target `../../../src/share/lib/cmm/sRGB.pf', needed by `/usr/src/jvms/jdk16u16/control/build/linux-amd64/lib/cmm/sRGB.pf'. Stop.

make[4]: *** No rule to make target `../../../src/share/lib/cmm/sRGB.pf', needed by `/usr/src/jvms/jdk16u16/control/build/linux-amd64/lib/cmm/sRGB.pf'. Stop.

これもjre/libの下にあったのでコピーしています。

# mkdir ../../j2se/src/share/lib/cmm
# cp -pi /home/masayuki/install/cmm/* ../../j2se/src/share/lib/cmm/

relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

make[4]: Entering directory `/usr/src/jvms/jdk16u16/j2se/make/sun/jdbc'
/usr/bin/gcc -shared -o /usr/src/jvms/jdk16u16/control/build/linux-amd64/tmp/sun/sun.jdbc.odbc/JdbcOdbc/libodbcinst.so dummyodbc.c
/usr/bin/ld: /tmp/cccOEmCj.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

jdbcのところで上記エラーが出ました。何故ここだけ…。CFLAGSを見てないようなのでMakefileに「-fPIC」をハードコード。

# diff -u ../../j2se/make/sun/jdbc/Makefile.org ../../j2se/make/sun/jdbc/Makefile
--- ../../j2se/make/sun/jdbc/Makefile.org       2012-02-27 18:26:50.000000000 +0900
+++ ../../j2se/make/sun/jdbc/Makefile   2012-03-03 22:11:06.000000000 +0900
@@ -85,10 +85,10 @@
 make_libs: $(TEMPDIR)/libodbcinst.so $(TEMPDIR)/libodbc.so
 
 $(TEMPDIR)/libodbcinst.so: dummyodbc.c  $(TEMPDIR)
-       $(CC) -shared -o $@ $<
+       $(CC) -fPIC -shared -o $@ $<
 
 $(TEMPDIR)/libodbc.so: dummyodbc.c $(TEMPDIR) 
-       $(CC) -shared -o $@ $<
+       $(CC) -fPIC -shared -o $@ $<
 
 clean::
        $(RM) -f $(TEMPDIR)/libodbcinst.so $(TEMPDIR)/libodbc.so

No rule to make target `/usr/src/jvms/jdk16u16/control/build/linux-amd64-fastdebug/lib/audio/soundbank.gm'

make[6]: *** No rule to make target `/usr/src/jvms/jdk16u16/control/build/linux-amd64-fastdebug/lib/audio/soundbank.gm', needed by `copy-files'. Stop.

またsoundbank.gmが。fastbugというモジュール?も作られていて、そちら側でエラーとなっています。前回と同様にコピー。

# mkdir ../build/linux-amd64-fastdebug/lib/audio
# cp -ip /home/masayuki/install/soundbank.gm ../build/linux-amd64-fastdebug/lib/audio

../../../src/solaris/native/sun/awt/awt_TopLevel.c:25:31: error: X11/Xmu/Editres.h: No such file or directory

../../../src/solaris/native/sun/awt/awt_TopLevel.c:25:31: error: X11/Xmu/Editres.h: No such file or directory

libXmu-develをインストール。

# yum install libXmu-devel -y