BuildingOpenJDK

From IcedTea

Jump to: navigation, search

IcedTea makes it easy to build OpenJDK, but sometimes it's necessary to build it yourself from a Mercurial forest, notably when upstreaming patches.

Assuming you want to build the tl repository (which covers a lot of the JDK, including the core libraries, networking, security, etc.) then you can proceed as follows:

$ hg fclone http://hg.openjdk.java.net/jdk7/tl
$ cd tl
$ unset JAVAC JAVACFLAGS JAVA_HOME JDK_HOME LD_LIBRARY_PATH CLASSPATH
$ (echo Building in ${BUILD_DIR} &&
   LANG=C make ALT_BOOTDIR=${ICEDTEA6_INSTALL} \
   ALT_OUTPUTDIR=${BUILD_DIR} \
   ALT_PARALLEL_COMPILE_JOBS=$PARALLEL_JOBS \
   HOTSPOT_BUILD_JOBS=$PARALLEL_JOBS \
   QUIETLY=""
  )
  • BUILD_DIR is the location where you want the resulting build to end up. If you don't specify ALT_OUTPUTDIR, then the build will be written to tl/build. I find it useful to separate the build directory to make it easier to keep the forest and delete the build. It also means you can place the two on different discs to speed up the build a little.
  • PARALLEL_JOBS also speeds up the build by enabling you to make use of multiple CPUs where available; this works like make -jn (which unfortunately doesn't work for OpenJDK) i.e. for n CPUs, set PARALLEL_JOBS to n+1.
  • ICEDTEA6_INSTALL= is the location of an install of IcedTea6 to use to bootstrap the new JDK
  • QUIETLY makes the HotSpot build more verbose, so you can see the invocations of e.g. javac

If you are building the IcedTea forest, you also have the option of building with the Zero port from Gary Benson of Red Hat. Add:

   CORE_BUILD=true ZERO_BUILD=true

The architecture and libffi location can be set automatically by running jdk/make/jdk_generic_profile.sh prior to make. Alternatively, you can set them as follows (replace amd64 with your architecture if required, the ARCHDEF version does need to be capitalised).

   ZERO_LIBARCH=amd64 \
   ZERO_ARCHDEF=AMD64 \
   ZERO_BITSPERWORD=64 \
   ZERO_ENDIANNESS=little \
   ZERO_ARCHFLAG=-m64 \
   LIBFFI_LIBS="-lffi" \

Other useful shell variables used during build process:

  • ALLOW_DOWNLOADS allows automatic download of source files of the projects JAXB and JAXWS
  • ALT_DROPS_DIR directory where downloaded sources of JAXB, JAWXS etc. are stored
Personal tools