Try this at home: Building the JDK (on Debian GNU/Linux)
One of my assignments here at Sun is to build the latest sources available at the Peabody site and provide some useful directions on how to do it. I use Debian GNU/Linux both at work and at home on my laptop, so I'll describe the build process on Debian. Probably someday I'll try to do it on another OS, say Windows or Mac OS X, when I get my hands on the computer with this OS installed. So, here we go...
Preparation: installing the necessary software
You will need to apt-get install the following software to build the JDK on Debian:
- binutils (>= 2.11.93.0.2-11). I used 2.16.1.
- gcc and g++ compilers (>= 3.2.2). I used gcc-4.0.2-2 which is stricter to the code than the 3.x versions, and probably some of the problems which I encountered appeared because of this. I plan to try 4.1.1 soon to see if there is a difference.
- JDK installation to bootstrap some part of the build (>= 1.5). I used JDK 1.5.0_06 which I downloaded from Sun's JDK 5.0 download site at the time when Sun's JDK had not made its way into Debian and Ubuntu distributions yet. Now you can simply do
apt-get install sun-java5-jdk
- make (>= 3.78.1). I used 3.80-9.
- zip (>= 2.2). I used 2.31-1.
- libcupsys2-dev. I used 1.2.2-1.
- libasound2-dev. I used 1.0.11-7.
Downloading the sources
Download the JDK 6 Source, JDK Binaries for Source Build 6, and Mozilla Binaries for Source Build 6 (Unix) from the page Java Platform, Standard Edition 6 Source Snapshot Releases. I did it a week ago, so I had a version b95. Some things may have changed since then.
You may also want to read the JDK 6 Readme and the Build Instructions.
Now you need to install the downloaded jars with sources and binaries, not unjar them:
$ java -jar jdk-6-rc-src-b95-jrl-10_aug_2006.jar
- Read and accept the Java Research License.
- Select the directory to install the sources to. Note: there isn't a single top directory in the archive, so make sure to create one beforehand.
$ java -jar jdk-6-rc-bin-b95-jrl-10_aug_2006.jar
- Read and accept the Module License Agreement.
- Select the directory to install the binaries (fonts, actually) to. Note: there isn't a single top directory in the archive. I installed the binaries into the same directory as sources and it worked out well.
$ java -jar jdk-6-rc-mozilla_headers-b95-unix-10_aug_2006.jar
- Read and accept the Mozilla Public License.
- Select the directory to install the sources to. Note: it doesn't have a single top directory in the archive. It can be safely installed into the same directory as sources.
Patching the source
GCC 4.x is stricter than the suggested GCC 3.2.2, so we need to fix some problems in order to build successfully. This part was very complicated in the days of the first beta (at least it had taken lots of my time in March, when I tried to guess how to fix those bugs). Now it is much easier, and you have the following cheat-sheet:
- GCC compile-time errors "static declaration of ‘foo’ follows non-static declaration": to fix them you need to remove (or comment out) the "static" keyword in the following files:
- j2se/src/solaris/hpi/native_threads/src/interrupt_md.c, line 115
- j2se/src/solaris/native/sun/awt/awt_dnd.c, line 172
- deploy/src/javaws/share/native/launchFile.c, line 66
- deploy/src/javaws/share/native/xmlparser.c, line 53
- GCC compile-time error: "PIC register ‘%ebx’ clobbered in ‘asm’" in file j2se/src/solaris/bin/java_md.c, line 1119. This one is very strange (I don't know what it means and whether the fix is safe), I'll try to contact the developer. To fix it, comment out ""%ebx"," in line 1140.
- In JDK 6 b95 I had the following two problems which were caused by bugs recently introduced to the Makefiles (/usr/local/java/jdk1.5.0_06 is a path to my bootstrap JDK installation):
/bin/cp: cannot stat `/usr/local/java/jdk1.5.0_06/jre/plugin/i386/ns7-gcc29/ns7/libjavaplugin_oji.so': No such file or directory
To fix it, apply the following patch to the file deploy/make/plugin/adapter/oji-gcc29-adapter/Makefile:26c26 < $(CP) $(ALT_GCC29_PLUGIN_LIB_PATH)/ns7/lib$(LIBRARY).so \ --- > $(CP) $(ALT_GCC29_PLUGIN_LIB_PATH)/lib$(LIBRARY).so \
/bin/cp: cannot stat `/usr/local/java/jdk1.5.0_06/jre/plugin/i386/ns7-gcc29/libjavaplugin_nscp_gcc29.so': No such file or directory
To fix it, comment out lines 23-24 in file deploy/make/plugin/nscore/linux-gcc29/Makefile
Building the source
Create the build.sh file in the directory where you installed the sources, binaries and Mozilla headers, with the following contents:
#!/bin/bash
# Alter the paths as needed
# /home/ivan/projects/peabody/src is a directory where I installed sources, binaries and Mozilla headers
unset JAVA_HOME
export ALT_BOOTDIR=/usr/local/java/jdk1.5.0_06 # bootstrap JDK location
export ALT_OUTPUTDIR=/home/ivan/projects/peabody/build # alter the path to which you want the JDK to be built
export ALT_DEVTOOLS_PATH=/usr/bin # path to 'make'
export BUILD_NUMBER=b95 # build number, you may want to change it
export ALT_MOZILLA_HEADERS_PATH=/home/ivan/projects/peabody/src/share/plugin
export ALT_GCC29_PLUGIN_LIB_PATH=${ALT_BOOTDIR}/jre/plugin/i386/ns7-gcc29
export SKIP_FASTDEBUG_BUILD=true # after building the normal build scsl starts building
export SKIP_DEBUG_BUILD=true # fastdebug and debug builds which is probably a bug
cd control/make
make dev
Note: You may also need to set LC_ALL=C if you have some locale-related problems during the build.
Then do
$ chmod u+x build.sh $ ./build.shcross your fingers and wait. If it bails out very quickly, you probably have some problems with paths which you set in build.sh. If you encounter some problems during the build, please write me, I'll do my best to find out how to fix them and then make the information available to the rest of the world!
Post Scriptum
- Be sure to run
$ bin/java -jar demo/jfc/Java2D/Java2Demo.jar
in the build directory after the successful build to see if Java works. - If you are curious, you can run
$ time ./build.sh
in order to find out how much time it takes to build the JDK on your computer. Here is the time output from the build on my 1.6GHz laptop:real 36m46.351s user 26m56.408s sys 2m59.288s
- There is a great blog post Honey, I built the JDK! (on Ubuntu) by Cay Horstmann, it saved me lots of time. Thanks, Cay!
Posted by Adam Sjøgren on August 25, 2006 at 12:19 AM MSD #
Posted by tarasov on August 25, 2006 at 01:59 AM MSD #
ESI,EDI,EBX and EBP however should not be modified across a function call (they can ofcourse be modified inside the calls but should be restored before returning).
It's possible that GCC by some reason chooses to do optimizations with the reserved registers and thus doesn't allow it to be clobbered. Kind of equating the _asm block to a function call?
So. if the code in question does modify ebx the safest "patch" would be to push it manually if you can guarantee that you can access the other variables.
Maybe you better file it as an report to those who are hacking the sources. :)
Posted by Jonas Lund on August 25, 2006 at 04:58 PM MSD #
Posted by trolly troller on August 27, 2006 at 04:12 AM MSD #
Posted by kotaiah katragadda on August 28, 2006 at 12:59 PM MSD #