Cross-compiling for the POWER8 with Docker
Continuing our series on cross-compiling ITK with CMake and Docker, we will cross-compile for the POWER8, which is a PowerPC 64 little endian system, i.e. ppc64le. This entry follows articles on cross-compiling for Windows and the Raspberry Pi with Docker. The POWER8 is interesting because it is a highly parallel system, running 8 threads on each core with up to 12 cores per chip. By cross-compiling, we can test patches that address dashboard build warnings so we can have a working system on which to perform parallel performance benchmarking.
When cross-compiling with Docker and CMake, there are three basic steps.
1) Get the cross-compiling toolchain
Obtaining the toolchain with Docker is easy — just download it with docker pull:
docker pull thewtex/cross-compiler-linux-ppc64le
2) Start up a container, mounting the source and build tree
If there is a source tree and build tree, e.g.
cd ~/src
git clone http://itk.org/ITK.git
mkdir -p ~/bin/ITK-build
Then mount these directories as Docker volumes when the container is started:
docker run --rm -it \
-v ~/src/ITK:/usr/src/ITK:ro \
-v ~/bin/ITK-build:/usr/src/ITK-build:rw \
thewtex/cross-compiler-linux-ppc64le
3) Point CMake to the CMAKE_TOOLCHAIN_FILE
Inside the container, the environmental variable CMAKE_TOOLCHAIN_FILE has been configured to point to the toolchain file CMake uses to inform itself about the build environment. Pass this file to CMake during configuration.
cd /usr/src/ITK-build
cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} ../ITK
make -j$(nproc)
Enjoy!