# OpenJDK PowerPC Port

This file contains some additional build instructions for the OpenJDK PowerPC Port for Linux and AIX. It complements the general OpenJDK README-builds.html file.

## Building on Linux/PPC64

Currently, i.e. all versions after revision ppc-aix-port-b01, should successfully build and run on Linux/PPC64. Passing `CORE_BUILD=true` on the build comamnd line will instruct the build system to create an interpreter-only version of the VM which is in general about an order of magnitude slower than a corresponding server VM with JIT compiler. But it is still fully functional (e.g. it passes JVM98) and can even be used to bootstrap itself. Starting with revision ppc-aix-port-b03, it is possible to build without `CORE_BUILD=true` and create a JIT-enabled version of the VM (containing the C2 "Server" JIT compiler).

Our current build system is a Power6 box running SLES 10.3 with gcc version 4.1.2 (in general, more recent Linux distributions should work as well).

### Building with the OpenJDK Linux/PPC64 port as bootstrap JDK

A precompiled build of ppc-aix-port-b03 is available for download. With it and together with the other build dependencies fulfilled as described in the main README-builds.html file you can build a debug version of the JDK from the top-level source directory with the following command line (additionally pass `CORE_BUILD=true` to build an interpreter-only version of the VM):

    > make FT_CFLAGS=-m64 LANG=C \
      ALT_BOOTDIR=<path_to>/jdk1.7.0-ppc-aix-port-b01 \
      ARCH_DATA_MODEL=64 \
      HOTSPOT_BUILD_JOBS=8 \
      PARALLEL_COMPILE_JOBS=8 \
      ALT_FREETYPE_LIB_PATH=/usr/local/lib \
      ALT_FREETYPE_HEADERS_PATH=/usr/local/include \
      ANT_HOME=/usr/local/apache-ant-1.8.4 \
      VERBOSE=true \
      CC_INTERP=true \
      OPENJDK=true \
      debug_build 2>&1 | tee build_ppc-aix-port_dbg.log

After the build finished successfully the results can be found under `./build/linux-ppc64-debug/`. Product and fastdebug versions can be build with the make targets `product_build` and `fastdebug_build` respectively (the build results will be located under `./build/linux-ppc64/` and `./build/linux-ppc64-fastdebug/`). On our transitional ppc-aix-port project page you can find the build logs of our regular nightly makes.

#### Problems with pre-installed ANT on newer Linux distros

Notice that pre-installed ANT version (i.e. ANT versions installed with the corresponding system package manager) may cause problems in conjunction with our bootstrap JDK. This is because they use various scripts from the jpackage project to locate specific Java libraries and jar files. These scripts (in particular `set_jvm_dirs()` in `/usr/share/java-utils/java-functions`) expect that executing "`java -fullversion`" will return a string starting with "java" but our OpenJDK port returns a string starting with "openjdk" instead.

The problem can be easily solved by either editing the regular expressions which parse the version string in `/usr/share/java-utils/java-functions` (or the respective file of your Linux distribution) or by installing a plain version of ANT from http://ant.apache.org/bindownload.cgi and passing its installation directory to the build via the `ANT_HOME` environment variable.

### Building with the IBM JDK for Linux/PPC64 as bootstrap JDK

It is also possible to build with an IBM JDK 7 bootstrap JDK (after all this is how we initially bootstrapped the port). But because the IBM JDK uses a different default implementation of the `idlj` and `rmic` compilers you will have to add the following two additional variables to the build command line to force the IBM JDK to fall back to the default Sun/Oracle version of the mentioned compilers (notice that the single quotes are crucial here to prevent the immediate expansion of `$(ALT_BOOTDIR)`):

    IDLJ='$(ALT_BOOTDIR)/bin/java -cp $(ALT_BOOTDIR)/lib/tools.jar com.sun.tools.corba.se.idl.toJavaPortable.Compile'
    RMIC='$(ALT_BOOTDIR)/bin/java -cp $(ALT_BOOTDIR)/lib/tools.jar sun.rmi.rmic.Main'

We successfully used build `pxp6470-20110827_01` of the IBM JDK but there have been reports on the ppc-aix-port-dev mailing list that newer version of the IBM JDK (starting with build `pxp6470sr1-20120330_01(SR1)`) require some additional tweaking. Neil Richards advised in that mail thread to "Just rename lib/ibmorbtools.jar to be something else. As the tools.jar tries to chain onto a file of that name, and that file contains the rmicext.properties files with the IBM-impl settings, moving that file off to one side should consistently cause rmic invocations to use the OpenJDK rmic IIOP generator. Approaching things this way would also mean one would not need to use the RMIC setting. (NB: One still need to use the IDLJ setting to use the OpenJDK idlj implementation, especially as moving the ibmorbtools.jar file aside also eliminates the IBM idlj implementation from the classpath)."

For historical reasons two old build logs of a debug and a product build bootstrapped with the IBM JDK are still available for inspection: output_ppc-aix-port_dbg.log, output_ppc-aix-port_opt.log.

### Running the OpenJDK Linux/PPC64 port

Running the freshly build VM should give the following output:

    > build/linux-ppc64-debug/bin/java -showversion HelloWorld
    openjdk version "1.7.0-internal"
    OpenJDK Runtime Environment (build 1.7.0-internal-jvmtests_2012_12_16_22_14-b00)
    OpenJDK 64-Bit Server VM (build 23.2-b04, mixed mode)

    HelloWorld

## Building on AIX/PPC64

Currently, i.e. all versions after revision ppc-aix-port-b02, should successfully build and run on AIX. Passing `CORE_BUILD=true` on the build comamnd line will instruct the build system to create an interpreter-only version of the VM which is in general about an order of magnitude slower than a corresponding server VM with JIT compiler. But it is still fully functional (e.g. it passes JVM98) and can even be used to bootstrap itself. Starting with revision ppc-aix-port-b03, it is possible to build without `CORE_BUILD=true` and create a JIT-enabled version of the VM (containing the C2 "Server" JIT compiler).

### Building with the OpenJDK AIX/PPC64 port as bootstrap JDK

A precompiled build of ppc-aix-port-b03 is available for download. We recommend using it or a self compiled OpenJDK version for AIX as bootstrap JDK.

### Building with the IBM JDK for AIX as bootstrap JDK

It is also possible to build with an IBM JDK 6 bootstrap JDK (after all this is how we initially bootstrapped the port). But because the IBM JDK uses a different default implementation of the `idlj` and `rmic` compilers you will have to rename or delete `lib/ibmorbtools.jar` and add the following additional variable to the build command line to force the IBM JDK to fall back to the default Sun/Oracle version of the IDLJ compiler (notice that the the single quotes are crucial here to prevent the immediate expansion of `$(ALT_BOOTDIR)`):

    IDLJ='$(ALT_BOOTDIR)/bin/java -cp $(ALT_BOOTDIR)/lib/tools.jar com.sun.tools.corba.se.idl.toJavaPortable.Compile'

### AIX build dependencies

Our current build system is based on AIX 5.3 in order to produce binaries which can be run on any AIX version higher than 5.3. However building on newer version of AIX should in general work equally well (from time to time we build on AIX 7.1 as well). It should be noticed that the current build infrastructure only supports the commercial XL C/C++ compilers from IBM so getting a copy of the XL C/C++ compiler suite 10.1 (or higher) is the first prerequisite that has to be fulfilled. You also need to to have the "AIXwindows Application Development Toolkit for X Extensions" (i.e. `X11.adt.ext`) package installed on your system. You can check this by doing:

    > lslpp -l X11.adt.ext
      Fileset                      Level  State      Description
      ----------------------------------------------------------------------------
    Path: /usr/lib/objrepos
      X11.adt.ext                7.1.0.0  COMMITTED  AIXwindows Application
                                                     Development Toolkit for X
                                                     Extensions

There are several other build dependencies (mostly described in the general README-builds.html file) which are a little more complicate to fulfill on AIX than on Linux platforms, but they are all freely available as described in the following section.

#### Mercurial & Python

The first thing to install is Mercurial. The Mercurial download wiki contains a special AIX section which links to http://www.lunch.org.uk/wiki/aix_packages. The site provides various RPM packeges for AIX 5.2 and higher. Download and install python-2.4.6-1.aix5.2.ppc.rpm and mercurial-2.3.1-0.aix5.2.ppc.rpm (with `rpm -i <package-name>.rpm`). All the "free" software packages will be installed by default into the `/opt/freeware` subdirectory under AIX which seems to be the equivalent to `/usr/local` on Linux platforms.

Notice that Python has a lot of dependencies on other freeware packages from `/opt/freeware` and you'll have to download and install them first before the installation of Python succeeds. Fortunately these packages can be downloaded directly from IBM's AIX Toolbox for Linux Applications site (if you don't have the RPM package manager installed already you'll first have to get the AIX installp image for the rpm package manager for POWER and install it with the command '`installp -qacXgd rpm.rte rpm.rte` '). On my AIX box, I had to install the following additional packages:

- bzip2-1.0.5-3.aix5.3.ppc.rpm
- db-3.3.11-4.aix5.1.ppc.rpm
- gdbm-1.8.3-5.aix5.2.ppc.rpm
- zlib-1.2.3-4.aix5.2.ppc.rpm
- readline-4.3-2.aix5.1.ppc.rpm

Python also requires OpenSSL which is available from the "AIX Toolbox for Linux Applications" as well, but only after signing in with a universal IBM user ID, which can be obtained for free (follow the link AIX Toolbox Cryptographic Content on the IBM AIX Toolbox download information page).

#### GNU Make

Unfortunately, the GNU Make package available from the "AIX Toolbox for Linux Applications" is too old (version 3.80 vs. 3.82) for building OpenJDK so we have to build our own one. Fortunately, that's not too hard:

    > wget http://ftp.gnu.org/gnu/make/make-3.82.tar.gz
    > tar -xzf make-3.82.tar.gz
    > cd make-3.82
    > CC=xlc_r ./configure --prefix=/opt/freeware
    > make
    > make install

#### Freetype, Cups and friends

Luckily, a sufficiently new version of Freetype is available from the "AIX Toolbox for Linux Applications" site as well. We need the Freetype development package which itself has dependencies as listed below:

- freetype2-2.3.9-1.aix5.2.ppc.rpm
- freetype2-devel-2.3.9-1.aix5.2.ppc.rpm
- zlib-devel-1.2.3-4.aix5.2.ppc.rpm
- pkg-config-0.19-6.aix5.2.ppc.rpm

Notice that the Freetype package will only install a single archive under `/opt/freeware/lib/libfreetype.a` but that archive contains both 32- and 64-bit versions of the `libfreetype.so` shared library:

    > ar -vt -Xany /opt/freeware/lib/libfreetype.a
    rwxr-xr-x     0/0     966393 Aug 21 01:42 2009 libfreetype.so.6
    rwxr-xr-x     0/0     1048680 Aug 21 01:41 2009 libfreetype.so.6

During a 64-bit build, the compiler will "magically" find the right version of the shared library from the archive.

Unfortunately the "AIX Toolbox for Linux Applications" site provides no Cups package, so I took cups-devel-1.6.1-1.aix5.3.ppc.rpm from http://www.perzl.org/aix/, another great site with precompiled open source software for AIX. The Cups development package has a lot of dependencies, but because the OpenJDK build only needs the Cups header files it is enough to force the installation of the Cups development package with `rpm -i --nodeps cups-devel-1.6.1-1.aix5.3.ppc.rpm`.

The default AIX `tar` may give you errors like "`/usr/bin/tar: arg list too long`" during the build process so we strongly recommend to install the tar-1.14-2.aix5.1.ppc.rpm package from IBM's AIX Toolbox for Linux Applications site.

#### Setting up the `PATH` and building

If you prepend `/opt/freeware/bin` to you `PATH` environment variable you should be finally able to start the build with the following command line (additionally pass `CORE_BUILD=true` to build an interpreter-only version of the VM):

    make debug_build \
      ALT_BOOTDIR=/usr/work/openjdk/nb/rs6000_64/last_known_good/output-jdk7u/j2sdk-image \
      ANT_HOME=/sapmnt/depot/tools/gen/java/OpenSource/Ant/1.8.0 \
      ALT_FREETYPE_LIB_PATH=/opt/freeware/lib \
      ALT_FREETYPE_HEADERS_PATH=/opt/freeware/include \
      ALT_CUPS_HEADERS_PATH=/opt/freeware/include \
      VERBOSE=true \
      CC_INTERP=true \
      OPENJDK=true \
      HOTSPOT_BUILD_JOBS=8 \
      PARALLEL_COMPILE_JOBS=8 2>&1 | tee /priv/d046063/OpenJDK/output-ppc-aix-port-debug.log

After the build finished successfully the results can be found under `./build/aix-ppc64-debug/`. Product and fastdebug versions can be build with the make targets `product_build` and `fastdebug_build` respectively (the build results will be located under `./build/aix-ppc64/` and `./build/aix-ppc64-fastdebug/`). On our transitional ppc-aix-port project page you can find the build logs of our regular nightly makes.

### Running the OpenJDK AIX/PPC64 port

Running the freshly build VM should give the following output:

    > build/aix-ppc64-debug/bin/java -showversion HelloWorld
    openjdk version "1.7.0-internal-debug"
    OpenJDK Runtime Environment (build 1.7.0-internal-jvmtests_2012_12_16_23_22-b00)
    OpenJDK 64-Bit Server VM (build 23.2-b04, mixed mode)

    HelloWorld

#### Fonts and Fontconfig (optional)

If you want to run AWT/Swing applications you have to install the fontconfig package from the "AIX Toolbox for Linux Applications" site as described before. You will also have to install at least the "AIXwindows Latin Type1 Fonts" package (`X11.fnt.iso_T1`) because Fontconfig and the `fontconfig.properties` file of the OpenJDK currently rely on the standard Type1 Postscript fonts. If you want to use other Type 1 or TrueType fonts (e.g. `X11.fnt.ucs.ttf`) you'll probably have to edit the local Fontconfig configuration file (under `/opt/freeware/etc/fonts/local.conf`) and the `<openjdk-path>/jre/lib/fontconfig.properties` file of your OpenJDK image.

Also remember that we currently dynamically link against Freetype (see build dependencies above) so if you copy the build results to another AIX machine you have to ensure that the new host has at least freetype2-2.3.9-1.aix5.2.ppc.rpm installed.

#### Memory requirements

Our VM is currently optimized for server class loads. This means that besides the usual Java heap settings which are controlled trough command line options the user has to make sure the environment provides reasonable data segment and the stack size limits. We recommend setting the stack size limit to 4MB (e.g. call '`ulimit -s 4000`') and the data segment limit to 1GB (e.g. call '`ulimit -d 1000000`'). Higher limits should be OK (the current limits can be inspected with '`ulimit -a`').