c/c++ · linux · minicloud · ppc64le

power: building your own version of Advance Toolchain

The IBM Advance Toolchain for Linux on Power is stand-alone set of open source development tools and run-time libraries allows users to take leading edge advantage of IBM’s latest POWER hardware features on Linux. It provides functionalities ahead of what is supported by current Linux distribution and does not rely on the system toolchain, requiring minimum dependencies. A new release of Advance Toolchain generally comprehends the addition of performance and improvements in a big set of packages: GNU Compiler Collection, GNU C library, GNU Binary Utilities, Decimal Floating Point Library,  AUXV Library, GNU Debugger, Performance analysis tools (oprofile, valgrind, itrace), Muti-core exploitation libraries (TBB, Userspace RCU, SPHDE) and several support libraries (libhugetlbfs, Boost, zlib, etc).

For your own convenience you do not need to build it from scratch. You can manually download and install it or configure the appropriated repository for your distribution. Click here to learn more about it. But, if you are willing to build it from scratch this post will guide you through the basic steps on building Advance Toolchain 8.0.

Getting Access to a Power Virtual Machine

Building Advance Toolchain is not simple. It is necessary to build a bunch of dependencies which requires a robust environment. In this example we are using a Ubuntu 14.04 Power virtual machine hosted at Minicloud with 50 Gb of disk, 16 Gb of memory and 4 vCPU. It is important to state that the largest flavor of VM available at Minicloud does not provide this amount of resource. Its is necessary to request this specific scenario by opening an issue.

IMPORTANT: ensure that your selected OS meets the one supported by the version of the Advance Toolchain you want to build.

Installing the Dependencies


sudo apt-get install git make binutils gcc g++ autoconf bison cvs debhelper docbook-xsl dpkg-sig fakeroot flex libbz2-dev libncurses5-dev libpopt-dev libqt4-dev libtool libxml2-utils subversion texinfo xsltproc xutils-dev zlib1g-dev openjdk-7-jdk pkg-config expect

A log about the installation can be found here.

Getting the Source Code

Advance Toolchain was open-sourced last year. Its source is hosted at Git Hub. To clone it do the following:


git clone https://github.com/advancetoolchain/advance-toolchain.git

Replacing IBM Java for OpenJDK

By default the build of Advance Toolchain will require the Java for building Oprofile, which needs a single header to enable the profiling of Java applications using JIT. By default the build will requires IBM Java, which can be manually downloaded and installed. But, as OpenJDK is already in our distro repository, it is easier to install it. You only need a few hacks go get it working:

1 – Replace the AT_NATIVE_PGMS_REQ value locates at configs/8.0/distros/ubuntu-14.mk for your version of OpenJDK installed. AT 8.0 requires the version 7.


AT_NATIVE_PGMS_REQ := pkg-config /usr/lib/jvm/java-7-openjdk-ppc64el/jre/bin/java

2 – Adjust the /scripts/utilities/java.sh b/scripts/utilities/java.sh by setting the variable supported_ver=”java-7-openjdk-ppc64el”


diff --git a/scripts/utilities/java.sh b/scripts/utilities/java.sh
index 8e5f37d..8146847 100755
--- a/scripts/utilities/java.sh
+++ b/scripts/utilities/java.sh
@@ -61,11 +61,11 @@ find_rpm_java ()
find_bin_java ()
{
# List of supported Java versions.
- local supported_ver="java-ppc64le-80 java-ppc64le-71"
-
+ local supported_ver="java-7-openjdk-ppc64el"
+ # /usr/lib/jvm/java-7-openjdk-ppc64el/include/jvmti.h
for version in ${supported_ver}; do
- if [[ -e "/opt/ibm/${version}/include/jvmti.h" ]]; then
- echo "/opt/ibm/${version}"
+ if [[ -e "/usr/lib/jvm/${version}/include/jvmti.h" ]]; then
+ echo "/usr/lib/jvm/${version}"
return 0
fi
done

Configuring Environment Variables

The Advance Toolchain Makefile has several options you can set according your needs but there is three you must set:

  • AT_CONFIGSET: inform the configset to use for the build.
  • DESTDIR: inform an alternate place to base and install everything.
  • BUILD_ARCH: inform the target architecture to generate the toolchain.

In our build the following values were set:

AT_CONFIGSET=8.0  
DESTDIR=/home/ubuntu/at8.0_build
BUILD_ARCH=ppc64le
This values can be set by exporting it:

export AT_CONFIGSET=8.0
export DESTDIR=/home/ubuntu/at8.0_build
export BUILD_ARCH=ppc64le

Building and Exercising Patience

Advance Toolchain will take about 4 hours to be completely built. In order to speed up the process a little bit you can leverage from the flag -j from make. Before using it, ensure you get the right amount of CPUs available:


ubuntu@at-firstbuild:~/advance-toolchain$ nproc
4

Before starting building it ensure you are in screen section. This is very helpful and allow you to disconnect from the VM and return later in order to check the build status.


screen #creates a new session

ctrl + a + d #disconnect from the current session

screen R #return to the previously created session

With the screen session set and the number of processors available you can issue the following command:


make -j4

The log of the whole build can be found here.

If you see the following lines, congratulations!!! You just built your own Advance Toolchain 🙂

....

Running ldconfig with final configs on installed at8.0-8
Completed at8.0-8 build
Begin DEB packaging for 8.0-8...
Begin to package source code for at8.0-8...
Completed packaging source code for at8.0-8
Completed DEB packages for 8.0-8
Collecting log information... done!

At the end of the build a new set of Advance Toolchain packages will be available for installation.


ubuntu@at-firstbuild:~/advance-toolchain/at8.0-8.ubuntu-14_ppc64le_ppc64le/debs$ ls
advance-toolchain-at8.0-devel_8.0-8_ppc64el.deb advance-toolchain-at8.0-runtime_8.0-8_ppc64el.deb advance-toolchain-perf_8.0-8_ppc64el.deb
advance-toolchain-at8.0-mcore-libs_8.0-8_ppc64el.deb advance-toolchain-devel_8.0-8_ppc64el.deb advance-toolchain-runtime_8.0-8_ppc64el.deb
advance-toolchain-at8.0-perf_8.0-8_ppc64el.deb advance-toolchain-mcore-libs_8.0-8_ppc64el.deb debhelper

Running the Functional Tests

Advance Toolchain has a bunch of functional which helps on validating it. Issue the following command to execute it:


make test

A log about the tests execution can be found here. If you find a failing test case, please report a bug.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s