Skip to content

Commit

Permalink
doc/ccache: move to “Advanced build system tricks”
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Dec 6, 2024
1 parent 113b5c5 commit 1b86fe3
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 81 deletions.
1 change: 0 additions & 1 deletion doc/doxygen/riot.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,6 @@ INPUT = ../../doc.txt \
src/build-in-docker.md \
../../tests/README.md \
src/dev-best-practices.md \
src/ccache.md \
src/comparing-build-sizes.md \
src/static-vs-dynamic-memory.md \
src/build-system-basics.md \
Expand Down
81 changes: 81 additions & 0 deletions doc/doxygen/src/advanced-build-system-tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,87 @@ You can configure your own files that will be parsed by the build system main
* Define your custom targets
* Override default targets

Speed-up builds with ccache {#ccache}
===========================

[`ccache`](https://ccache.samba.org/) is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again.

Usually, the initial build takes a little (5% - 20%) longer, but repeated builds are up to ten times faster.
Using `ccache` is safe, as `ccache` tries very hard to not mess up things and falls back to a normal compile if it cannot ensure correct output.

There's one drawback: without further tweaking, `gcc` stops emitting colored output.

Setup
-----

- Install using the package manager of your distribution, e.g., on Ubuntu or Debian:

~~~~~~~~~~~~~~~~~~~
# sudo apt-get install ccache
~~~~~~~~~~~~~~~~~~~

- Set `CCACHE` variable to `ccache`:

~~~~~~~~~~~~~~~~~~~
# export CCACHE=ccache
~~~~~~~~~~~~~~~~~~~

- (Optionally) add the above export line to your `~/.profile`

Result
------

Build without `ccache`:

~~~~~~~~~~~~~~~~~~~
[kaspar@booze default (master)]$ time BOARD=samr21-xpro make clean all
Building application "default" for "samr21-xpro" with MCU "samd21".
[...]
text data bss dec hex filename
37016 180 6008 43204 a8c4 /home/kaspar/src/riot/examples/default/bin/samr21-xpro/default.elf
real 0m12.321s
user 0m10.317s
sys 0m1.170s
[kaspar@booze default (master)]$
~~~~~~~~~~~~~~~~~~~

First build with `ccache` enabled:

~~~~~~~~~~~~~~~~~~~
[kaspar@booze default (master)]$ time BOARD=samr21-xpro make clean all
Building application "default" for "samr21-xpro" with MCU "samd21".
[...]
text data bss dec hex filename
37016 180 6008 43204 a8c4 /home/kaspar/src/riot/examples/default/bin/samr21-xpro/default.elf
real 0m15.462s
user 0m12.410s
sys 0m1.597s
[kaspar@booze default (master)]$
~~~~~~~~~~~~~~~~~~~

Subsequent build with `ccache` enabled:

~~~~~~~~~~~~~~~~~~~
[kaspar@booze default (master)]$ time BOARD=samr21-xpro make clean all
Building application "default" for "samr21-xpro" with MCU "samd21".
[...]
text data bss dec hex filename
37016 180 6008 43204 a8c4 /home/kaspar/src/riot/examples/default/bin/samr21-xpro/default.elf
real 0m2.157s
user 0m1.213s
sys 0m0.327s
[kaspar@booze default (master)]$
~~~~~~~~~~~~~~~~~~~

Analyze dependency resolution {#analyze-depedency-resolution}
=============================

Expand Down
80 changes: 0 additions & 80 deletions doc/doxygen/src/ccache.md

This file was deleted.

0 comments on commit 1b86fe3

Please sign in to comment.