4.4. Using the Compiler Cache

Compiling source code can be quite slow, and frequently recompiling that code can be extremely inefficient. Sourcery CodeBench Lite includes a tool named arm-none-eabi-cs that solves this problem via caching.

The caching tool intercepts compiler invocations, generates a unique signature from the source files, command-line parameters, and other environmental information, and serves the object file and warning messages directly from the cache. If the object is not currently cached then the real compiler is called, and the cache updated.

The first time you build with caching enabled you can expect the build to take 10-30% longer. The second time you build it might be 80% faster. The memory and CPU usage savings may also mean it is possible to use higher levels of build parallelism (e.g. make -j) and gain even more performance.

arm-none-eabi-cs is based on the well-known open-source tool ccache. Refer to man cs for more information.

4.4.1. Invoking arm-none-eabi-cs

There are two ways you can run the caching tool with command-line builds.

  • Explicitly invoke arm-none-eabi-cs. For example, like this:

    > arm-none-eabi-cs arm-none-eabi-gcc -c hello.c

    or like this:

    > make CC="arm-none-eabi-cs arm-none-eabi-gcc"
  • Add installdir/bin/cache to the head of your PATH, and run your normal compile command:

    > export PATH=installdir/bin/cache:installdir/bin:$PATH
    > arm-none-eabi-gcc -c hello.c