CrossCompilingOpenJDK

From jalimo (inactive) Wiki
Jump to: navigation, search

Contents

Cross-compiling OpenJDK

This document describes the steps needed to get OpenJDK cross-compiled using Icedtea. Initial cross-compilation efforts have been done as part of the OpenEmbedded project and as such some of the constraints applied during the build stem from this fact.

However this guide aims at explaining all the needed steps in a way that you can either do them manually or use it for another cross-compilation build environment (e.g. OpenWRT, T2, etc.).

If you rather want to run an automated crosscompile of OpenJDK using Jalimo and Icedtea then read this guide instead: http://icedtea.classpath.org/wiki/CrossCompileFaq

Warning

A word of warning. Cross-compiling OpenJDK is not an easy undertaking and this guide is by no means exhaustive. You should have good knowledge of your operating system and your target system.

Prerequisites

This guide assumes that you have good knowledge about the following topics:

* make
* patch
* GNU Automake
* Java, OpenJDK and IcedTea
* cross-compilation

Furthermore this guides assumes that you have access to the following tools:

* javah
* javac
* java
* jar

Each of the following software packages can provide them:

* Eclipse Java Compiler (ecj) -> javac
* JamVM/Cacao + GNU Classpath -> javah, java, jar
* GNU GCJ -> javac, javah, java, jar

You can, of course, also use a previous installation of either the proprietary JDK (at least 1.5) or OpenJDK itself. In the OpenEmbedded project we use the ECJ, JamVM/Cacao and GNU Classpath combination which we build from source as well. If you interested in an overview about this, have a look at the OE Wiki.

Goals

This guide will explain all steps that are needed for building the following software packages:

  • OpenJDK (Zero port)

This is the most basic variant. It consists of the OpenJDK JavaSE 6 class library and the Hotspot virtual machine in interpreted mode. The interpreter is written in C++ and no (= zero) assembly and as such highly portable albeit slow at runtime. The VM supports all advanced features like debugging, annotations, etc.

  • OpenJDK (Shark port)

This gives you the same package as above but compiles Hotspot with a new and very experimental JIT compiler support that uses the LLVM libraries. LLVM contains JIT backends for various architectures including ARM, PowerPC and MIPS (assuming you want to cross-compile for a 'genuine' embedded system :) ). However as of today (2009-02-05) there are outstanding issues with at least the ARM backend that make running Shark impossible. Bug reports are posted - we hope those issues are resolved soon.

  • OpenJDK with CacaoVM runtime

The last option is about replacing the default virtual machine Hotspot with the CacaoVM. CacaoVM has built-in JIT compiler support for various architectures and is very cross-compile friendly. Unfortunately the VM lacks support for advanced features like JVMTI.

Conventions and terms

  • build machine

The build machine is the one that does the compilation. If this guide tells you to compile *for* the build machine this is done because there is interest in getting a specific binary which can be run on the build machine.

  • target machine

This is the machine you want to compile OpenJDK for.

  • bootstrap JDK, final JDK

These terms come from the way IcedTea is built: IcedTea is compiling the OpenJDK and Hotspot sources twice. In the first run it compiles the so-called 'bootstrap JDK' and then it builds the 'final JDK'. The reason for this is that OpenJDK itself requires a working JDK to get compiled. The bootstrap JDK however is modified in ways that it can be build without the need for another JDK and accepts a GNU Classpath-based VM instead. Thus the main contribution of IcedTea is that the dependency chain for OpenJDK becomes:

GNU Classpath/GCJ -> bootstrap JDK -> OpenJDK

instead of

JDK 1.5 (proprietary) -> OpenJDK.
  • staging directory

OpenEmbedded like other cross-compilation environments employs the use of a staging directory. This directory acts like the root directory of your target device when it comes to installing headers and libraries. In OE we actually have two staging directories: One for the build and one for the target machine. The former is also called native staging and is used to install all kinds of binaries, scripts and of course headers and libraries which are needed be subsequent build processes. The use of staging directories is not mandatory for this guide. Whenever it tells you to copy some stuff into staging skip this part and instead remember where the respective files are when they are referenced at a later point.

Major steps

These are the major steps to get the cross-compilation done: 1 build bootstrap JDK for build machine 1 build bootstrap and final JDK for target

The second step differs slightly for Zero, Shark and Cacao. This guide will explain the Zero variant in consecutive order. For Shark and Cacao the sections will only describe the differences.

Bootstrap JDK (build machine)

Building the bootstrap JDK for the build machine is a mandatory step. You might think that it is unneeded because you can get a fully working JDK through your distribution's package feeds. However those packages lack some binaries that are internal to the build process. By building the bootstrap JDK yourself you will get them.

This guide uses version 1.3.1 of IcedTea.

Files to download

Patches:

Icedtea patches:

Dependencies

You need to get hold of the following packages. Either you build them on your own or extend your build environment to build them for you.

  • Freetype
  • Xalan-j
  • Xerces-j
  • Rhino
  • libx11
  • xproto
  • libxt
  • Classpath' JNI header

All those packages must be compiled for your build machine, of course.

Additionally the following tools need to be available:

In OpenEmbedded we enforced that the bootstrap JDK does not require Alsa, CUPS, Xinerama, libxp, libpng, libjpeg and giflib. If you do not want to follow that practice have the development packages for those libraries ready.

Patches

In this section the patches are explained. The goal is that you understand each part and will be able to refresh the patch for newer IcedTea versions. Furthermore the patch implements some of the constraints given by OpenEmbedded. If some constraint is not important for you, you can skip the respective lines.

The disable-library-checks.patch does what it says. It disables IcedTea looking for cups, alsa, libpng, libjpeg, giflib, libxtst and the xinerama headers. If compiling against the build machine's variants of those libraries is OK for you, you can leave this patch away. Furthermore the disable-library-checks.patch adds two IcedTea patches. These patches will applied by the IcedTea build system itself.

Please note that the patches modify autotools support files and as such you are required to rerun 'autoreconf' after that. For this to succeed you need to have Automake 1.10 available.

build-hacks-native.patch
Index: icedtea6-1.3.1/Makefile.am
===================================================================
--- icedtea6-1.3.1.orig/Makefile.am	2008-12-19 15:59:42.000000000 +0100
+++ icedtea6-1.3.1/Makefile.am	2008-12-19 16:03:21.000000000 +0100
@@ -142,7 +142,7 @@
         "JRE_RELEASE_VERSION=1.6.0_$(COMBINED_VERSION)" \
         "HOTSPOT_RELEASE_VERSION=1.6.0_$(COMBINED_VERSION)" \
 	"LANG=C" \
-	"PATH=$(abs_top_builddir)/bootstrap/jdk1.6.0/bin:/usr/bin:/bin:/usr/sbin:/sbin" \
+	"PATH=$(abs_top_builddir)/bootstrap/jdk1.6.0/bin:$(OE_PATH):/usr/bin:/bin:/usr/sbin:/sbin" \
 	"ALT_BOOTDIR=$(ICEDTEA_BOOT_DIR)" \
 	"ALT_BINARY_PLUGS_PATH=$(abs_top_builddir)/bootstrap/jdk1.7.0" \
 	"BUILD_ARCH_DIR=$(BUILD_ARCH_DIR)" \
@@ -212,7 +212,7 @@
         "JRE_RELEASE_VERSION=1.6.0_$(COMBINED_VERSION)" \
         "HOTSPOT_RELEASE_VERSION=1.6.0_$(COMBINED_VERSION)" \
 	"LANG=C" \
-	"PATH=$(abs_top_builddir)/bootstrap/jdk1.6.0/bin:/usr/bin:/bin:/usr/sbin:/sbin" \
+	"PATH=$(abs_top_builddir)/bootstrap/jdk1.6.0/bin:$(OE_PATH):/usr/bin:/bin:/usr/sbin:/sbin" \
 	"ALT_BOOTDIR=$(ICEDTEA_BOOT_DIR)" \
 	"ALT_BINARY_PLUGS_PATH=$(abs_top_builddir)/bootstrap/jdk1.7.0" \
 	"BUILD_ARCH_DIR=$(BUILD_ARCH_DIR)" \

These hunks add the OpenEmbedded path of the staging directory to path that is active when OpenJDK is built. You can certainly replace OE_PATH with PATH in your build. In IcedTea 1.4 this is already done.

@@ -246,6 +246,10 @@
 	"FT2_LIB=$(FREETYPE2_LIBS)" \
 	"ALT_PARALLEL_COMPILE_JOBS=$(PARALLEL_JOBS)" \
 	"HOTSPOT_BUILD_JOBS=$(PARALLEL_JOBS)" \
+	"OE_CFLAGS=$(OE_CFLAGS)" \
+	"OE_CPPFLAGS=$(OE_CPPFLAGS)" \
+	"OE_CXXFLAGS=$(OE_CXXFLAGS)" \
+	"OE_LDFLAGS=$(OE_LDFLAGS)" \
	"JAVAC=" \
	"RHINO_JAR=$(RHINO_JAR)" \
	"JAR_KNOWS_ATFILE=$(JAR_KNOWS_ATFILE)" \

This plays together with some changes in OpenJDK makefiles and makes sure that certain compiler and linker flags are used in your build. E.g. if the policy of your distribution expects that all binaries are compiled with --hash-style=gnu this hunk makes it possible.

@@ -321,31 +325,31 @@
 endif

 stamps/download.stamp:
-if USE_ALT_OPENJDK_SRC_ZIP
-else
-	if ! echo "$(OPENJDK_MD5SUM)  $(OPENJDK_SRC_ZIP)" \
-	  | $(MD5SUM) --check ; \
-	then \
-	  if [ $(OPENJDK_SRC_ZIP) ] ; \
-	  then \
-	    mv $(OPENJDK_SRC_ZIP) $(OPENJDK_SRC_ZIP).old ; \
-	  fi ; \
-	  $(WGET) $(OPENJDK_URL)$(OPENJDK_SRC_ZIP) -O $(OPENJDK_SRC_ZIP); \
-	fi
-endif
+#if USE_ALT_OPENJDK_SRC_ZIP
+#else
+#	if ! echo "$(OPENJDK_MD5SUM)  $(OPENJDK_SRC_ZIP)" \
+#	  | $(MD5SUM) --check ; \
+#	then \
+#	  if [ $(OPENJDK_SRC_ZIP) ] ; \
+#	  then \
+#	    mv $(OPENJDK_SRC_ZIP) $(OPENJDK_SRC_ZIP).old ; \
+#	  fi ; \
+#	  $(WGET) $(OPENJDK_URL)$(OPENJDK_SRC_ZIP) -O $(OPENJDK_SRC_ZIP); \
+#	fi
+#endif
 if WITH_CACAO
 if !USE_SYSTEM_CACAO
 if USE_ALT_CACAO_SRC_ZIP
 else
-	if ! echo "$(CACAO_MD5SUM)  $(CACAO_SRC_ZIP)" \
-	 | $(MD5SUM) --check ; \
-	then \
-	 if [ $(CACAO_SRC_ZIP) ] ; \
-	 then \
-	   mv $(CACAO_SRC_ZIP) $(CACAO_SRC_ZIP).old ; \
-	 fi ; \
-	 $(WGET) $(CACAO_URL)$(CACAO_SRC_ZIP) -O $(CACAO_SRC_ZIP); \
-	fi
+#	if ! echo "$(CACAO_MD5SUM)  $(CACAO_SRC_ZIP)" \
+#	 | $(MD5SUM) --check ; \
+#	then \
+#	 if [ $(CACAO_SRC_ZIP) ] ; \
+#	 then \
+#	   mv $(CACAO_SRC_ZIP) $(CACAO_SRC_ZIP).old ; \
+#	 fi ; \
+#	 $(WGET) $(CACAO_URL)$(CACAO_SRC_ZIP) -O $(CACAO_SRC_ZIP); \
+#	fi
 endif
 endif
 endif

IcedTea 1.3.1 has the problem that although a --with-openjdk-srcdir argument is used it will download the OpenJDK sources on its own. The first part of this hunk disables that. In OpenEmbedded we want the environment take over the job of downloading sources.

The second part basically implements the same for the Cacao sources. Actually this hunk is unneeded as we do not build the bootstrap JDK with Cacao (this in turn is clever if you want to run your build on e.g. a PowerPC host).

@@ -557,22 +561,22 @@
 	$(DISTRIBUTION_PATCHES)
 
 stamps/extract.stamp: stamps/download.stamp
-	if ! test -d openjdk ; \
-	then \
-	  mkdir openjdk ; \
-	  $(TAR) xf $(OPENJDK_SRC_ZIP) -C openjdk; \
-	  chmod -R ug+w openjdk ; \
-	  sh $(abs_top_srcdir)/fsg.sh ; \
-	fi
+#	if ! test -d openjdk ; \
+#	then \
+#	  mkdir openjdk ; \
+#	  $(TAR) xf $(OPENJDK_SRC_ZIP) -C openjdk; \
+#	  chmod -R ug+w openjdk ; \
+#	  sh $(abs_top_srcdir)/fsg.sh ; \
+#	fi
 if WITH_CACAO
 if !USE_SYSTEM_CACAO
-	if ! test -d cacao ; \
-	then \
-	  mkdir cacao ; \
-	  $(TAR) xf $(CACAO_SRC_ZIP) -C cacao ; \
+#	if ! test -d cacao ; \
+#	then \
+#	  mkdir cacao ; \
+#	  $(TAR) xf $(CACAO_SRC_ZIP) -C cacao ; \
 	  dir=$$(basename cacao/cacao-*) ; \
 	  ln -s $$dir cacao/cacao ; \
-	fi
+#	fi
 endif
 endif
 if WITH_VISUALVM

The above hunk disables the preparation of the OpenJDK and Cacao tarball. In OE (and as such in this guide) we will do these steps ourselves.

@@ -875,6 +879,7 @@
 # ===============================
 
 # bootstrap/ecj.
+# Treat SYSTEM_GCJ_DIR as the one that contains the jni and jawt headers
 stamps/bootstrap-directory-ecj.stamp: stamps/native-ecj.stamp
 	mkdir -p bootstrap/ecj/bin stamps/
 	ln -sf $(JAVA) bootstrap/ecj/bin/java
@@ -891,19 +896,12 @@
 	if test -d $(SYSTEM_GCJ_DIR); \
 	then \
 	  mkdir -p bootstrap/ecj/jre/lib; \
-	  ln -sf $(SYSTEM_GCJ_DIR)/jre/lib/$(JRE_ARCH_DIR) \
-	    bootstrap/ecj/jre/lib/; \
-	  if ! test -d bootstrap/ecj/jre/lib/$(INSTALL_ARCH_DIR); \
-	  then \
-	    ln -sf ./$(JRE_ARCH_DIR) \
-	      bootstrap/ecj/jre/lib/$(INSTALL_ARCH_DIR); \
-	  fi; \
 	  mkdir -p bootstrap/ecj/include; \
-	  for i in $(SYSTEM_GCJ_DIR)/include/*; do \
+	  for i in $(SYSTEM_GCJ_DIR)/*; do \
 	    test -r $$i | continue; \
 	    i=`basename $$i`; \
 	    rm -f bootstrap/ecj/include/$$i; \
-	    ln -s $(SYSTEM_GCJ_DIR)/include/$$i bootstrap/ecj/include/$$i; \
+	    ln -s $(SYSTEM_GCJ_DIR)/$$i bootstrap/ecj/include/$$i; \
 	  done; \
 	else \
 	  echo $(SYSTEM_GCJ_DIR) " cannot be found. Try reconfiguring with " \

This hunk explains itself because of the comment at the top. For better compatibility the build steps for the target machine include the creation of a fakejdk directory which mimics GCJ directly layout and removes the need for this hunk.

Index: icedtea6-1.3.1/javac.in
===================================================================
--- icedtea6-1.3.1.orig/javac.in	2008-12-19 15:59:42.000000000 +0100
+++ icedtea6-1.3.1/javac.in	2008-12-19 15:59:45.000000000 +0100
@@ -30,10 +30,8 @@
   NEW_ARGS=`echo $NEW_ARGS | sed -e 's/-Werror//1'`
 fi
 
-if [ -e @abs_top_builddir@/native-ecj ] ; then
-    @abs_top_builddir@/native-ecj -1.5 -nowarn $bcoption $NEW_ARGS ;
-else
-    CLASSPATH=@ECJ_JAR@${CLASSPATH:+:}$CLASSPATH \
-     @JAVA@ org.eclipse.jdt.internal.compiler.batch.Main -1.5 -nowarn $bcoption $NEW_ARGS
-fi
+# Compiling hotspot-tools consumes tons of memory and exceeds any default
+# limits for jamvm and cacao.
+CLASSPATH=@ECJ_JAR@${CLASSPATH:+:}$CLASSPATH \
+@JAVA@ -Xmx4096m org.eclipse.jdt.internal.compiler.batch.Main -1.5 -nowarn $bcoption $NEW_ARGS

This explains itself. As of IcedTea 1.4 this is not strictly neccessary anymore since you can point the build at your Java compiler executable. You can also point it at a script which calls the compiler with the neccessary -Xmx arguments.

IcedTea patches

Besides the patches that modify IcedTea's file itself there are two patches which will be added to the IcedTea patch list and get applied by the build automatically. For the support of future versions you need to understand.

icedtea-ecj-disable-sanitychecks.patch

This patch is straighforward and easy. It disables some of the built-in sanity check of OpenJDK. With the patch applied it will not look for Alsa, CUPS and few others anymore.

icedtea-ecj-disable-compilation.patch

This is the beasty and important one. It realizes the suppression of compiling certain parts of the bootstrap JDK such as Alsa and CUPS but also a few helper files which turned out to be troublesome.

Index: openjdk-ecj/jdk/make/sun/awt/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/sun/awt/Makefile	2009-01-05 14:03:28.636859446 +0100
+++ openjdk-ecj/jdk/make/sun/awt/Makefile	2009-01-05 14:03:51.394478355 +0100
@@ -180,7 +180,8 @@
 include $(BUILDDIR)/common/Mapfile-vers.gmk
 include $(BUILDDIR)/common/Library.gmk
 
-build: fontconfigs
+#build: fontconfigs
+build:
 
 
 ifeq ($(PLATFORM), windows)
@@ -534,9 +535,9 @@
             -I$(PLATFORM_SRC)/native/$(PKGDIR) \
 	    $(EVENT_MODEL)
 
-ifeq ($(PLATFORM), linux)
-LDFLAGS += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
-endif
+#ifeq ($(PLATFORM), linux)
+#LDFLAGS += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
+#endif
 
 LDFLAGS += -L$(LIBDIR)/$(LIBARCH)/$(TSOBJDIR) \
 	   $(AWT_RUNPATH)

This hunk disables the generation of fontconfig files. Normally this would process an XML-based fontconfig file into a binary one. For that to work it needs some internal class. Additionally this disables linker arguments that would require motif.

Index: openjdk-ecj/jdk/make/javax/sound/jsoundalsa/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/javax/sound/jsoundalsa/Makefile	2009-01-05 14:03:28.677944535 +0100
+++ openjdk-ecj/jdk/make/javax/sound/jsoundalsa/Makefile	2009-01-05 14:03:51.394478355 +0100
@@ -44,34 +44,35 @@
 # Files
 #
 
-FILES_c = \
-	Utilities.c \
-	$(DAUDIOFILES_c) \
-	$(MIDIFILES_c) \
-	$(PORTFILES_c)
+FILES_c = 
+#	Utilities.c \
+#	$(DAUDIOFILES_c) \
+#	$(MIDIFILES_c) \
+#	$(PORTFILES_c)
 
 # platform dependent files
-FILES_c += \
-	PLATFORM_API_LinuxOS_ALSA_CommonUtils.c   \
-	PLATFORM_API_LinuxOS_ALSA_PCM.c     \
-	PLATFORM_API_LinuxOS_ALSA_PCMUtils.c   \
-	PLATFORM_API_LinuxOS_ALSA_MidiIn.c  \
-	PLATFORM_API_LinuxOS_ALSA_MidiOut.c \
-	PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
-	PLATFORM_API_LinuxOS_ALSA_Ports.c
-
-FILES_export = \
-	$(DAUDIOFILES_export) \
-	$(MIDIFILES_export) \
-	$(PORTFILES_export)
+#FILES_c += \
+#	PLATFORM_API_LinuxOS_ALSA_CommonUtils.c   \
+#	PLATFORM_API_LinuxOS_ALSA_PCM.c     \
+#	PLATFORM_API_LinuxOS_ALSA_PCMUtils.c   \
+#	PLATFORM_API_LinuxOS_ALSA_MidiIn.c  \
+#	PLATFORM_API_LinuxOS_ALSA_MidiOut.c \
+#	PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
+#	PLATFORM_API_LinuxOS_ALSA_Ports.c
+
+FILES_export = 
+#FILES_export = \
+#	$(DAUDIOFILES_export) \
+#	$(MIDIFILES_export) \
+#	$(PORTFILES_export)
 
-LDFLAGS += -lasound
+#LDFLAGS += -lasound
 
 CPPFLAGS += \
-	-DUSE_DAUDIO=TRUE \
-	-DUSE_PORTS=TRUE  \
-	-DUSE_PLATFORM_MIDI_OUT=TRUE \
-	-DUSE_PLATFORM_MIDI_IN=TRUE \
+	-DUSE_DAUDIO=FALSE \
+	-DUSE_PORTS=FALSE  \
+	-DUSE_PLATFORM_MIDI_OUT=FALSE \
+	-DUSE_PLATFORM_MIDI_IN=FALSE \
 	-I$(SHARE_SRC)/native/com/sun/media/sound
 
 #

This part disables the native part of the javax.sound implementation and as such suppresses Alsa usage.

Index: openjdk-ecj/jdk/make/sun/splashscreen/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/sun/splashscreen/Makefile	2009-01-05 14:03:28.697947270 +0100
+++ openjdk-ecj/jdk/make/sun/splashscreen/Makefile	2009-01-05 14:03:51.429968313 +0100
@@ -32,7 +32,8 @@
 #
 # Files
 #
-include FILES_c.gmk
+#include FILES_c.gmk
+FILES_c = 
 
 FILES_java = \
     java/awt/SplashScreen.java
@@ -62,9 +63,9 @@
 CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE
 
 ifneq ($(PLATFORM), windows)
-  CFLAGS += -DWITH_X11
-  CPPFLAGS += -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
-  OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpng -ljpeg -lgif -lz -lpthread
+#  CFLAGS += -DWITH_X11
+#  CPPFLAGS += -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
+#  OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpng -ljpeg -lgif -lz -lpthread
 else # PLATFORM
   CFLAGS += -DWITH_WIN32
   OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib 
@@ -79,7 +80,7 @@
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/image/jpeg
 vpath %.c   $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen
 
-CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
+#CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
 
 ifeq ($(PLATFORM), linux)
   ifeq ($(ARCH_DATA_MODEL), 64)

This disables splashscreen support and as such removes the need for various X11 and imaging libraries.

Index: openjdk-ecj/jdk/make/sun/xawt/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/sun/xawt/Makefile	2009-01-05 14:03:28.705948993 +0100
+++ openjdk-ecj/jdk/make/sun/xawt/Makefile	2009-01-05 14:05:01.236723989 +0100
@@ -41,15 +41,16 @@
 #
 # Files
 #
-include FILES_c_unix.gmk
-include FILES_export_unix.gmk
+#include FILES_c_unix.gmk
+FILES_c = 
+#include FILES_export_unix.gmk
 AUTO_FILES_JAVA_DIRS = sun/awt/X11
 AUTO_JAVA_PRUNE = WrapperGenerator.java
 
 LDFLAGS += -L$(OPENWIN_LIB)
 
 ifeq ($(PLATFORM), linux)
-LDFLAGS += -lpthread
+#LDFLAGS += -lpthread
 dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
 endif
 
@@ -86,16 +87,19 @@
 vpath %.c   $(PLATFORM_SRC)/native/sun/java2d/opengl
 vpath %.c   $(PLATFORM_SRC)/native/sun/java2d/x11
 
-OTHER_LDLIBS = $(LIBM) -lawt -lXext -lX11 -ldl \
-                   $(LDFLAGS_COMMON) $(AWT_RUNPATH) $(OTHER_LDFLAGS) -lXtst -lXi
+#OTHER_LDLIBS = $(LIBM) -lawt -lXext -lX11 -ldl \
+#                   $(LDFLAGS_COMMON) $(AWT_RUNPATH) $(OTHER_LDFLAGS) -lXtst -lXi
 
 ifeq  ($(PLATFORM), solaris)
 CPPFLAGS += -DFUNCPROTO=15
 dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
 endif
 
-CPPFLAGS += -I$(CUPS_HEADERS_PATH)
+#CPPFLAGS += -I$(CUPS_HEADERS_PATH)
 
+# Normally we would like to patch these includes away but
+# we need them for the successfull compilation of the sizer
+# executables.
 CPPFLAGS += -DXAWT -DXAWT_HACK \
         -I$(TEMPDIR)/../../sun.awt/awt/CClassHeaders \
         -I$(PLATFORM_SRC)/native/sun/awt \
@@ -124,10 +128,10 @@
 
 ifeq ($(PLATFORM), linux)
 # Allows for builds on Debian GNU Linux, X11 is in a different place 
-  CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
-              -I/usr/include/X11/extensions \
-              -I$(MOTIF_DIR)/include \
-              -I$(OPENWIN_HOME)/include 
+#  CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
+#              -I/usr/include/X11/extensions \
+#              -I$(MOTIF_DIR)/include \
+#              -I$(OPENWIN_HOME)/include 
 endif
 
 ifeq ($(PLATFORM), solaris)
@@ -238,18 +242,20 @@


Until here it disables XAWT compilation.


 	    $(SIZER_DIR) $(XLIBTYPES) "sizer" $(subst .,,$(suffix $(basename $@)))
 
 $(SIZES): $(SIZERS)
-	@if [ "$(DOHACK)$@" = "true$(PREDEFINED_SIZES)" ]; then \
-	    $(ECHO) COPYING $(PREDEFINED_SIZES_TMPL) into $@; \
-	    $(CP) $(PREDEFINED_SIZES_TMPL) $@; \
-	    $(CHMOD) +w $@;\
-	else	\
-	    $(ECHO) GENERATING $@; \
-	    $(WRAPPER_GENERATOR_DIR)/sizer$(suffix $@) > $@; \
-	fi
-	@if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \
-	    $(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
-	    $(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
-	fi	
+	touch $(SIZES)
+#
+#	@if [ "$(DOHACK)$@" = "true$(PREDEFINED_SIZES)" ]; then \
+#	    $(ECHO) COPYING $(PREDEFINED_SIZES_TMPL) into $@; \
+#	    $(CP) $(PREDEFINED_SIZES_TMPL) $@; \
+#	    $(CHMOD) +w $@;\
+#	else	\
+#	    $(ECHO) GENERATING $@; \
+#	    $(WRAPPER_GENERATOR_DIR)/sizer$(suffix $@) > $@; \
+#	fi
+#	@if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \
+#	    $(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
+#	    $(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
+#	fi	
 
 $(TEMPDIR)/.gen.wrappers: $(SIZES) $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES)
 	$(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \

This disables that the so called sizer binaries are actually run. They do not make sense for this build anyway since XAWT is disabled.

Index: openjdk-ecj/jdk/make/sun/jawt/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/sun/jawt/Makefile	2009-01-05 14:03:28.745945541 +0100
+++ openjdk-ecj/jdk/make/sun/jawt/Makefile	2009-01-05 14:03:51.457944054 +0100
@@ -36,7 +36,8 @@
 ifeq ($(PLATFORM), windows)
 FILES_cpp = jawt.cpp
 else # PLATFORM
-FILES_c = jawt.c
+FILES_c = 
+#FILES_c = jawt.c
 endif # PLATFORM
 
 FILES_h = $(INCLUDEDIR)/jawt.h \

Disables the JAWT library.

Index: openjdk-ecj/jdk/make/sun/jpeg/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/sun/jpeg/Makefile	2009-01-05 14:03:28.769946554 +0100
+++ openjdk-ecj/jdk/make/sun/jpeg/Makefile	2009-01-05 14:03:51.457944054 +0100
@@ -37,7 +37,8 @@
 #
 # Files
 #
-include FILES_c.gmk
+FILES_c = 
+#include FILES_c.gmk
 
 AUTO_FILES_JAVA_DIRS = sun/awt/image com/sun/imageio/plugins/jpeg
 

Disables JPEG support library.

Index: openjdk-ecj/jdk/make/common/shared/Defs-java.gmk
===================================================================
--- openjdk-ecj.orig/jdk/make/common/shared/Defs-java.gmk	2009-01-05 14:03:28.841947165 +0100
+++ openjdk-ecj/jdk/make/common/shared/Defs-java.gmk	2009-01-05 14:03:51.461946411 +0100
@@ -36,14 +36,14 @@
 # Memory related -J flags that all uses of java tools should use.
 #
 JAVA_MEM_FLAGS   = -Xmx$(MAX_VM_MEMORY)m
-ifeq ($(ARCH), ia64)
+#ifeq ($(ARCH), ia64)
   # Special flags for javac on ia64 to work around a VM problem with
   #   bad code generation during inlining (what version had this problem?):
   #   Suspect this may not be needed anymore.
-  JAVA_MEM_FLAGS   += -Xms$(MAX_VM_MEMORY)m -XX:-Inline
-else
-  JAVA_MEM_FLAGS   += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
-endif
+#  JAVA_MEM_FLAGS   += -Xms$(MAX_VM_MEMORY)m -XX:-Inline
+#else
+#  JAVA_MEM_FLAGS   += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
+#endif
 
 # 
 # All java tools (javac, javah, and javadoc) run faster with certain java

JamVM does not like the XX:PermSize and XX:MaxPermSize parameters. So we disables them here.

Index: openjdk-ecj/jdk/src/solaris/native/sun/awt/CUPSfuncs.c
===================================================================
--- openjdk-ecj.orig/jdk/src/solaris/native/sun/awt/CUPSfuncs.c	2009-01-05 14:03:28.969947133 +0100
+++ openjdk-ecj/jdk/src/solaris/native/sun/awt/CUPSfuncs.c	2009-01-05 14:03:51.465972022 +0100
@@ -26,8 +26,10 @@
 #include <jni.h>
 #include <jni_util.h>
 #include <dlfcn.h>
+#if 0
 #include <cups/cups.h>
 #include <cups/ppd.h>
+#endif
 
 //#define CUPS_DEBUG
 
@@ -37,6 +39,7 @@
 #define DPRINTF(x, y)
 #endif
 
+#if 0
 typedef const char* (*fn_cupsServer)(void);
 typedef int (*fn_ippPort)(void);
 typedef http_t* (*fn_httpConnect)(const char *, int);
@@ -56,7 +59,7 @@
 fn_ppdClose j2d_ppdClose;
 fn_ppdFindOption j2d_ppdFindOption;
 fn_ppdPageSize j2d_ppdPageSize;
-
+#endif
 
 /*
  * Initialize library functions.
@@ -65,6 +68,7 @@
 JNIEXPORT jboolean JNICALL
 Java_sun_print_CUPSPrinter_initIDs(JNIEnv *env,
                                          jobject printObj) {
+#if 0
   void *handle = dlopen("libcups.so.2", RTLD_LAZY | RTLD_GLOBAL);
 
   if (handle == NULL) {
@@ -131,6 +135,8 @@
   }
 
   return JNI_TRUE;
+#endif
+	return JNI_FALSE;
 }
 
 /*
@@ -141,6 +147,7 @@
 Java_sun_print_CUPSPrinter_getCupsServer(JNIEnv *env,
                                          jobject printObj)
 {
+#if 0
     jstring cServer = NULL;
     const char* server = j2d_cupsServer();
     if (server != NULL) {
@@ -152,6 +159,8 @@
         }
     }
     return cServer;
+#endif
+	return NULL;
 }
 
 /*
@@ -162,8 +171,11 @@
 Java_sun_print_CUPSPrinter_getCupsPort(JNIEnv *env,
                                          jobject printObj)
 {
+#if 0
     int port = j2d_ippPort();
     return (jint) port;
+#endif
+	return 0;
 }
 
 
@@ -177,6 +189,7 @@
                                       jstring server,
                                       jint port)
 {
+#if 0
     const char *serverName;
     serverName = (*env)->GetStringUTFChars(env, server, NULL);
     if (serverName != NULL) {
@@ -187,6 +200,7 @@
             return JNI_TRUE;
         }
     }
+#endif
     return JNI_FALSE;
 }
 
@@ -199,6 +213,7 @@
                                          jobject printObj,
                                          jstring printer)
 {
+#if 0
     ppd_file_t *ppd;
     ppd_option_t *optionTray, *optionPage;
     ppd_choice_t *choice;
@@ -304,6 +319,8 @@
     j2d_ppdClose(ppd);
     unlink(filename);
     return nameArray;
+#endif
+	return NULL;
}
 
 
@@ -315,6 +332,7 @@
                                          jobject printObj,
                                          jstring printer)
 {
+#if 0
     ppd_file_t *ppd;
     ppd_option_t *option;
     ppd_choice_t *choice;
@@ -374,4 +392,6 @@
     j2d_ppdClose(ppd);
     unlink(filename);
     return sizeArray;
+#endif
+	return NULL;
 }

Although we disabled XAWT this file is still compiled through the headless AWT variant. With the above patch hunk CUPS is not needed at all.

Index: openjdk-ecj/corba/make/common/Defs.gmk
===================================================================
--- openjdk-ecj.orig/corba/make/common/Defs.gmk	2009-01-05 14:03:28.889946037 +0100
+++ openjdk-ecj/corba/make/common/Defs.gmk	2009-01-05 14:03:51.461946411 +0100
@@ -449,11 +449,11 @@
 # Tool flags
 #
 ASFLAGS         = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
-CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS)
-CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
-CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
+CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(OE_CFLAGS)
+CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(OE_CXXFLAGS)
+CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) $(OE_CPPFLAGS) \
 		  $(DEFINES) $(OPTIONS:%=-D%)
-LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
+LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS) $(OE_LDFLAGS)
 LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
 LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
 		  $(OTHER_LINTFLAGS)
Index: openjdk-ecj/jdk/make/common/Defs.gmk
===================================================================
--- openjdk-ecj.orig/jdk/make/common/Defs.gmk	2009-01-05 14:03:28.909945604 +0100
+++ openjdk-ecj/jdk/make/common/Defs.gmk	2009-01-05 14:03:51.465972022 +0100
@@ -662,11 +662,11 @@
 # Tool flags
 #
 ASFLAGS         = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
-CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS)
-CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
-CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
+CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(OE_CFLAGS)
+CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(OE_CXXFLAGS)
+CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) $(OE_CPPFLAGS) \
 		  $(DEFINES) $(OPTIONS:%=-D%)
-LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
+LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS) $(OE_LDFLAGS)
 LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
 LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
 		  $(OTHER_LINTFLAGS)
Index: openjdk-ecj/hotspot/build/linux/makefiles/vm.make
===================================================================
--- openjdk-ecj.orig/hotspot/build/linux/makefiles/vm.make	2009-01-05 14:03:28.949945270 +0100
+++ openjdk-ecj/hotspot/build/linux/makefiles/vm.make	2009-01-05 14:03:51.465972022 +0100
@@ -193,6 +193,7 @@
 LIBS_VM   += $(LLVM_LIBS)
 endif
 
+LFLAGS_VM = $(OE_LDFLAGS)
 LINK_VM = $(LINK_LIB.c)
 
 # rule for building precompiled header

The above hunks make it possible to specify custom compiler and link flags to the OpenJDK build. Remember the Makefile.am changes in the build-hacks-native.patch which allow specifiying these. These are not terribly important.

Index: openjdk-ecj/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
===================================================================
--- openjdk-ecj.orig/jdk/src/share/classes/java/awt/GraphicsEnvironment.java	2009-01-05 14:03:28.861944030 +0100
+++ openjdk-ecj/jdk/src/share/classes/java/awt/GraphicsEnvironment.java	2009-01-05 14:03:51.461946411 +0100
@@ -113,7 +113,7 @@
      * @since 1.4
      */
     public static boolean isHeadless() {
-        return getHeadlessProperty();
+        return true;
     }
 
     /**
Index: openjdk-ecj/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java
===================================================================
--- openjdk-ecj.orig/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java	2009-01-05 14:03:28.969947133 +0100
+++ openjdk-ecj/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java	2009-01-05 14:03:51.469946665 +0100
@@ -244,6 +244,8 @@
                  * that might be specified.
                  */
                 fontConfig = createFontConfiguration();
+								if (fontConfig == null)
+									return null;
                 getPlatformFontPathFromFontConfig();
 
                 String extraFontPath = fontConfig.getExtraFontPath();
Index: openjdk-ecj/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java
===================================================================
--- openjdk-ecj.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java	2009-01-05 14:03:28.989945803 +0100
+++ openjdk-ecj/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java	2009-01-05 14:03:51.473951349 +0100
@@ -899,7 +899,8 @@
 
     // Implements SunGraphicsEnvironment.createFontConfiguration.
     protected FontConfiguration createFontConfiguration() {
-        return new MFontConfiguration(this);
+//        return new MFontConfiguration(this);
+			return null;
     }
     public FontConfiguration
         createFontConfiguration(boolean preferLocaleFonts,

The three changes above are the most evil modification. The reason for them is simple: In the real OpenJDK build at one point the JavaVM will be run in headless mode in order to access some font classes. That codepath that is modified in SunGraphicsEnvironment would normally cause the loading of some native library which we do not have. With the shown modifications we can prevent that and allow the tool to succeed its work.

Index: openjdk-ecj/jdk/make/launchers/Makefile
===================================================================
--- openjdk-ecj.orig/jdk/make/launchers/Makefile	2009-01-05 14:03:28.989945803 +0100
+++ openjdk-ecj/jdk/make/launchers/Makefile	2009-01-05 14:03:51.473951349 +0100
@@ -57,7 +57,7 @@
 endif
 # Run MAKE $@ for all generic launchers
 define make-all-launchers
-$(call make-launcher, appletviewer, sun.applet.Main, , )
+#$(call make-launcher, appletviewer, sun.applet.Main, , )
 $(call make-launcher, apt, com.sun.tools.apt.Main, , )
 $(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
 $(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
@@ -94,7 +94,7 @@
   -J-Dcom.sun.CORBA.POA.ORBServerId=1, )
 $(call make-launcher, pack200, com.sun.java.util.jar.pack.Driver, , --pack)
 $(call make-launcher, pluginappletviewer, sun.applet.PluginMain, , )
-$(call make-launcher, policytool, sun.security.tools.PolicyTool, , )
+#$(call make-launcher, policytool, sun.security.tools.PolicyTool, , )
 $(call make-launcher, rmic, sun.rmi.rmic.Main, , )
 $(call make-launcher, rmid, sun.rmi.server.Activation, , )
 $(call make-launcher, rmiregistry, sun.rmi.registry.RegistryImpl, , )

Policytool and Appletviewer depend on the splashscreen support. Since we disabled that, we need to disable them, too.

Arch and Libarch

OpenJDK has the concept of an arch and a libarch. Both are variables and their values are used for the creation of directories. Since we fumble around with the build system a lot, we sometimes have to create a directory ourselves. You can use the following shell function to derive arch and libarch for your platform.

# OpenJDK uses slightly different names for certain arches. We need to know
#	this to create some files which are expected by the build.
case "${TARGET_ARCH}" in
   x86_64)
     arch=amd64
     libarch=amd64
   ;;
   i586|i686)
     arch=i586
     libarch=i386
   ;;
   *)
     arch=${TARGET_ARCH}
     libarch=${TARGET_ARCH}
   ;;
 esac

${TARGET_ARCH} is what uname -m would tell you on your target system. Whenever this guide uses arch or libarch as variable replace its value with what this function would create for them on your machine.

Preparation

Create a working directory ($WORKDIR) and the Icedtea tarball in it (this directory becomes our source dir or $S). Then apply the normal patches against IcedTea.

Create an openjdk directory inside $S and then unpack the OpenJDK tarball in it. Only Sun knows why thy are distributing a tarbomb ...

Next run these commands to fix file attributes (WTF!) and clean the directory from any non-DFSG compliant content (fsg.sh is from IcedTea itself):

	chmod -R ug+w ${S}/openjdk
	sh ${S}/fsg.sh

Finally copy the two IcedTea patches into the patches folder inside $S:

	cp icedtea-ecj-disable-sanitychecks.patch ${S}/patches
	cp icedtea-ecj-disable-compilation.patch ${S}/patches

From there they will be available to the build (Remember that the disable-library-checks.patch adds them to the build machinery.)

Configuration

Use the following arguments for IcedTea's configure:

--disable-liveconnect
--disable-docs
--disable-pulse-java

For our bootstrap JDK we do not need these.

--with-ecj-jar=${STAGING_DATADIR_JAVA_NATIVE}/ecj-bootstrap.jar

Point this to the jar file of your ecj. You are highly recommended to use ECJ as it seems to be the only compiler that is thoroughly tested with IcedTea.

--with-java=${STAGING_BINDIR_NATIVE}/java

Point this at your JavaVM. Cacao and JamVM can be used.

--with-javah=${STAGING_BINDIR_NATIVE}/gjavah
--with-jar=${STAGING_BINDIR_NATIVE}/gjar
--with-rmic=${STAGING_BINDIR_NATIVE}/grmic

Point those at your javah, jar and rmic tools. They can be provided by GNU Classpath' builtin ones.

--with-libgcj-jar=${STAGING_DATADIR_NATIVE}/classpath/glibj.zip

Point this at your class library. This can be GNU Classpath' glibj.zip.

--with-xalan2-jar=${STAGING_DATADIR_NATIVE}/java/xalan2.jar
--with-xalan2-serializer-jar=${STAGING_DATADIR_NATIVE}/java/serializer.jar
--with-xerces2-jar=${STAGING_DATADIR_NATIVE}/java/xercesImpl.jar
--with-rhino=${STAGING_DATADIR_NATIVE}/java/rhino.jar

Point this at your xalan, xerces and rhino jar files.

--with-gcj-home=${STAGING_INCDIR_NATIVE}/classpath

Point this at the directory into which you have installed GNU Classpath' header files. It should contain jni.h, jawt.h and jni_md.h.

--with-openjdk-src-dir=${WORKDIR}/openjdk

This argument is broken in IcedTea 1.3.1. It can be provided in automated build environments to ease transition to a newer IcedTea when avaiable. Otherwise forget about it.

--with-ecj=${STAGING_BINDIR_NATIVE}/ecj-bootstrap
--with-javac=${STAGING_BINDIR_NATIVE}/ecj-bootstrap

Normally those should point to your javac executable. However IcedTea 1.3.1 is broken and only accepts the --with-ecj-jar option properly.

Build steps

  • do_compile*

/*TODO*/

Zero: Build bootstrap and final JDK (target machine)

This guide uses the following files:

* icedtea6-1.4
* openjdk-...
* hotspot-...
* build-hacks.patch
* icedtea-crosscompile.patch
* ...

/*TODO*/

build-hacks.patch

/*TODO*/

icedtea-crosscompile.patch

/*TODO*/

Dependencies

* ant
* rhino
* lib---
* cups
* alsa
* libxt
* libxp
* libx11 (diet-libx11 is not compatible)

/*TODO*/

Preparation

  • Unpacking OpenJDK sources, putting binaries at specific locations, etc.* (do_unpackpost)

/*TODO*/

Configuration

Use the following arguments for IcedTea's configure:

* --enable-*
* --disable-*

/*TODO*/

Build steps

  • do_compile*

/*TODO*/

Shark: Build bootstrap and final JDK (target machine)

Building OpenJDK with the Shark port of the runtime is quite easy when LLVM is already build. When preparing this for OpenEmbedded it turned out that compiling LLVM is the most difficult aspect. As such it will be explained here.

Dependencies

Besides all the dependencies of the Zero build you additionally need llvm 2.4 to which the following patches have been applied:

* [***]

/*TODO*/

Cross-compiling LLVM

First of all you need a non-cross build of LLVM first. However this is very easy and only consists of running:

./configure
make
make install

(Depending on your environment you want to install into a staging directory.)

Although LLVM has built-in cross-compilation support this failed badly within OpenEmbedded. It was needed to patch the makefiles to disable some of their features (see #Dependencies). With that in place the build steps consist of doing:

/*TODO*/

Putting LLVM's output into a staging directory turned out to be another issue. If you do not make use of a separate staging directory you can skip this part because then the llvm-config script works correctly for you. When a staging directory is used you need to apply the following sed commands on the script to fix some paths.

/*TODO*/

Configuration

Instead of --enable-zero use --enable-shark.

Preparation and build steps

Rejoice. Use the same steps as for Zero.

Cacao: Build bootstrap and final JDK (target machine)

Building OpenJDK with the CacaoVM runtime is in many ways similar to the Zero build. IcedTea even contains support for building Cacao as part of its build process. However in this guide we do not make use of this since it turned out to be easier that way.

While building Cacao it normally creates cacaoh which it wants to execute. As such we need to create it first in a non-cross build.

Compiling cacaoh tool

Use the following arguments to cacao's configure: /*TODO*/

In order to build this tool you only need to issue the following make commands:

make -C toolbox
make -C src/cacao/cacaoh

/*TODO*/

When finished copy the binary from src/vm/cacao/.libs/cacaoh to your staging directory.

Compiling cacao for target

Use the following arguments to cacao's configure: /*TODO*/

Building consists of issuing:

make

Copy vm.zip and libjvm.so into your staging directory.

Preparation

Create a cacao directory inside the icedtea6-1.3.1 directory and copy vm.zip and libjvm.so to .... .

Configuration

Instead of --enable-zero use --with-cacao. When running make always add USE_SYSTEM_CACAO=1.

Build steps

The build steps for OpenJDK+Cacao differ a bit. The good news is that after some initial differences the rest is the same.

/*TODO*/