Tuesday, February 3, 2015

Using Icecream to speed up the LibreOffice Android build

Lots of us is using Icecream distributed compiler for the LibreOffice development. It is usually the first thing we set up at a hackfest, to speed up the build for everybody (given that it only seldom occurs that all the people build at the same time).

The LibreOffice FOSDEM HackFest is no exception; Markus even brought a MacMini with a Linux VM to provide even more building power.

The problem was that I decided to hack on Android-related stuff; and the setup for Icecream was something that I had on my TODO, never achieved, and now it became really paiful. There was a small problem that was confusing me for a while, but finally I have a how-to!
  1. Make sure you have a recent enough repo that contains this fix
  2. Create cross-compile package for your environment like this (adapt the paths of course):
    /usr/lib/icecc/icecc-create-env --gcc /local/libreoffice/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc /local/libreoffice/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
  3. icecc-create-env will create a tarball with a hash instead of a readable name, rename it to something sensible, let's say
    /local/libreoffice/android/arm-linux-androideabi-4.9.tar.gz
  4. Find out how exactly is the compiler called. Just do ./autogen.sh > .log 2>& .log, and search for arm-linux-androideabi-gcc and arm-linux-androideabi-g++. You will need it with all the options that are there, it is quite a long command line!
  5. Modify your autogen.input to start like (we'll:
    CC=icecc [the_command_line_with_options_for_arm-linux-androideabi-gcc]
    CXX=icecc [the_command_line_with_options_for_arm-linux-androideabi-g++]
    --with-parallelism=10
    --enable-icecream
Now every time you start a new shell, just do:

export ICECC_VERSION=/local/libreoffice/android/arm-linux-androideabi-4.9.tar.gz

start the build:

./autogen.sh
make

and enjoy the lightning fast compilation for Android! :-)

Update: Since this commit, it is not necessary to set the ICECC_VERSION in every env any more, the one from the ./autogen.sh time is preserved - it has to be in sync with CC/CXX setting anyway. In other words, you can just add ICECC_VERSION to autogen.input the same way you have added CC/CXX there:

CC=icecc [the_command_line_with_options_for_arm-linux-androideabi-gcc]
CXX=icecc [the_command_line_with_options_for_arm-linux-androideabi-g++]
ICECC_VERSION=/path/to/the/tarball
--with-parallelism=10
--enable-icecream
...your other options...

1 comment:

  1. Hello,
    I am trying to create sdk of libreoffice for one of my projects. I have make the project successfully using old method but while running on android device the app is crashing as it is trying to access a file present in root folder of device while opening a document. But it is working fine in emulator. Can you help me here in this?

    ReplyDelete