Icecream Scratchbox Howto

mairas (Talk | contribs)
(New page: = Icecream + Scratchbox HOWTO = ''Original instructions written by Anderson Lizardo. This version copied verbatim from the INdT wiki.'' From Icecream web page <ref>http://en.opensuse.org...)
Newer edit →

Revision as of 08:05, 8 February 2010

Contents

Icecream + Scratchbox HOWTO

Original instructions written by Anderson Lizardo. This version copied verbatim from the INdT wiki.

From Icecream web page [1]:

"Icecream is created by SUSE and is based on ideas and code by distcc. Like distcc it takes compile jobs from your build and distributes it to remote machines allowing a parallel build on several machines you've got."

This document describes how to use icrecream for parallel compilation inside Scratchbox.

Compiling icecc

To be able to use icecc both on ARM and x86 targets, we need to compile it use the "special" host-gcc and host-g++ compilers inside a scratchbox target. The binaries generated by these compilers can then be run from any target, because they link to scratchbox own libraries.

We will use only the icecc client, and share the icecc daemon with the host. This allows using icecc both inside and outside scratchbox.

To compile icecc, enter a scratchbox target (the architecture set on it is not important) and unpack the icecc source tarball (you can download it from [2]). Next, enter the source directory and run:

sbox > ./configure --prefix=/scratchbox/tools CC=host-gcc CXX=host-g++
sbox > make

Installing icecc

The next commands should be done outside scratchbox, as root.

Copy the "client/icecc" binary to /scratchbox/tools/bin and a "icecc++" symlink necessary for compiling C++ programs:

host# cp -a client/icecc /scratchbox/tools/bin/icecc
host# ln -sfn icecc /scratchbox/tools/bin/icecc++

Preparing toolchain tarballs

To make sure that the correct compiler is used, it is necessary to create a tarball containing all files required by the toolchain. This can be done either manually, or by using the "icecc_create_env_sbox.sh" script.

  1. Download icecc_create_env_sbox.sh script.
  2. (Optional) Edit the script and change the "sbox_dir" variable, in case your scratchbox is not installed in /scratchbox
  3. Run the script for each target you wish to use icecc for. E.g.:
  4. host$ ./icecc_create_env_sbox.sh maemo5-armv7
    host$ ./icecc_create_env_sbox.sh maemo5-i486
    

For each run, two files will be created:

  • a tarball named <md5>.tar.gz, where <md5> is the MD5 signature of the tarball contents.
  • a symbolic link to this tarball, named "icecc_box-<compiler_name>.tar.gz"

These tarballs will be used later when running icecc. It is important that they uniquely identify the toolchain, because all peers in the build network will use the same tarball, and will cache the toolchain locally using that name. Therefore we use the MD5 signature, plus a symlink to easily map it to the actual Scratchbox toolchain name.

Using icecc

In order to run icecc, you need to set the ICECC_VERSION environment variable to point to the tarball created in previous section. Note that this variable will be set to different values, depending on which target icecc will run (ARM or x86).

The ICECC_VERSION variable has the following format:

<build_architecture>:<cross_toolchain_for_target>

Hint:

You can add the following snippet to ~/.bashrc (inside scratchbox) and have that variable set automatically to the right value (change tarball names and path accordingly):

sbox_compiler="$(sb-conf show --compiler)"
# use the tarball name with the MD5, avoiding conflicting names in peer caches
icecc_tarball="$(readlink -f $HOME/icecc_sbox-$sbox_compiler.tar.gz)"
if [ -f "$icecc_tarball" ]; then
export ICECC_VERSION="i486:$icecc_tarball"
fi
unset icecc_tarball sbox_compiler

Done! To effectively use icecc to compile code, set the compiler to "icecc". This is usually done by setting the CC and CXX environment variables.

Using icecc "transparently" under Scratchbox

Modifying build systems to use "icecc" instead of the defaults g++/gcc can be error prone. Therefore, the following instructions can be used to make it transparent:

  1. Create a "/host_usr/bin" directory if it does not exist already:
  2. sbox > mkdir -p /host_usr/bin

    (This directory is automatically added by Scratchbox to beginning of the PATH, therefore it is not necessary to add it manually.)

  3. Create "gcc" and "g++" symlinks into that directory, pointing to icecc:
  4. sbox > ln -sfn /scratchbox/tools/bin/icecc /host_usr/bin/gcc
    sbox > ln -sfn /scratchbox/tools/bin/icecc++ /host_usr/bin/g++
    
  5. Disable Scratchbox redirection for the gcc and g++ binaries:
  6. sbox > export SBOX_REDIRECT_IGNORE=/usr/bin/gcc,/usr/bin/g++
    

You can now build applications normally and they will automatically use icecc when calling gcc or g++.

References

  1. http://en.opensuse.org/Icecream
  2. ftp://ftp.suse.com/pub/projects/icecream/