Friday Apr 27, 2007

I have been trying to build OpenJDK HotSpot VM on
my Windows XP machine for some time now without much success or
resource on Google. So this weekend I decided to use the rain as my
excuse to get the build going once and for ever. Good thing is that I
was able to build OpenJDK HotSpot VM
via command line as well as NetBeans using the C/C++
Pack
.

Before I go over some details, here is the executive summary. *DO NOT USE MS VS 2005*.
The reason for this is that VS 2005 has deprecated
a few CRT POSIX functions
such as strcpy with strcpy_s that
affects building of OpenJDK HotSpot VM on
Windows. You can bypass the warnings by defining _CRT_NONSTDC_NO_DEPRECATE. This is extra work that is unnecessary.

Now
here are the steps I followed to get a successful OpenJDK HotSpot VM
build on a Pentium class Windows XP machine.

  1. Download
    and install cygwin (You can install bare minimal packages as defined at JDK
    Builds
  2. Install
    a licensed copy of MS VS .NET 2003, DirectX SDK and MSLU as defined in Windows
    Checklist
    . DirectX, MSLU are needed only if you decide to
    build the whole JDK and not just OpenJDK HotSpot VM
  3. Download and install OpenJDK HotSpot VM source
  4. *IMPORTANT*
    - Your cygwin installation has link.exe and MS VS .NET 2003 also has
    link.exe. What our build system needs is the link.exe from MS VS .NET
    2003 and not cygwin. I will leave it to your experience to decide how
    you want this to happen. (Hint: Put MS VS .NET 2003 ahead of cygwin in
    your path or replace cygwin/bin/link.exe with that from MS VS .NET 2003)
  5. Now
    you are almost ready. Open a command prompt, execute vcvars32.bat which
    sets your MS VS .NET 2003 environment, execute cygwin.bat that logs you
    into cygwin shell. Make sure that MS VS .NET 2003 is ahead of
    /cygdrive/... in your path
  6. Now set ALT_BOOTDIR and
    ALT_JDK_IMPORT_PATH to JAVA_HOME. (Note: when building JDK, you should
    not set CLASSPATH or JAVA_HOME). Also make sure that your USER and
    USERNAME does not have spaces in them
  7. 'cd <your HotSpot installation path>/make;make -f Makefile' and you are all set

Now to build the same under NetBeans, I did the following.

  1. I am assuming that you've already installed the NetBeans C/C++ Pack over your NetBeans 5.5
  2. Using
    the same command prompt that you used above, start NetBeans. This
    ensures that all the necessary environment variables are set when your
    NetBeans starts up.
  3. Go to "File-->New Project-->C/C++ Development-->C/C++ Project From Existing Code"
  4. Browse and select existing Makefile from your <HotSpot installation path>/make
  5. Here
    you have the option of how to invoke the make commend. You can choose
    to use the standard one or use what you did in the command prompt -
    '${MAKE} -f Makefile'
  6. Now your IDE is all set to build OpenJDK HotSpot
    VM
    . All you have to do is to right mouse on the project and
    call "Build Project" or "Clean and Build Project"

The
same steps are applicable if you want to build JDK using the JRL
license from OpenJDK. A few
catches here are:

  1. You will need the DirectX SDK and MSLU.
  2. You
    will need to install both JDK source as well as "JDK Binaries for
    Source Build X". This binary contains the Lucida font binary that is
    needed for compilation
  3. You will need to get all copies of StarWars movie and some beer ;-)" alt=";-)" class="smiley" src="http://blogs.sfbay.sun.com/images/smileys/wink.gif" /> (because it too me well over 5-6 hrs to complete the build)

Good
luck with your experiment on building JDK or HotSpot. As always
comments are welcome and if you do have some additional gotchas, please
feel free to add them.

 Thanks,
Sandeep

Comments:

Post a Comment:
Comments are closed for this entry.