Faster incremental builds with Ninja

Rabin Vincent
2016-06-27T18:50:45Z

Ninja is a small build system with a focus on speed. More details at
https://ninja-build.org/.

I made an experimental Ninja build file generator for the kernel. The
purpose was to see how much we could decrease compile times (especially
to detect errors) for single file changes. Results on my machine and
x86 defconfig:

| Change | make -j8 | make -j8 objectname | ninja |
| --------------------------| -------- | ------------------- | ------ |
| No changes | 2.254s | 0.731s | 0.065s |
| One change, compile error | 1.225s | 0.765s | 0.077s |
| One change, full link | 5.915s | NA | 4.482s |

The link time unsuprisingly dominates when performing small changes, but
as can be seen the time until the start of compilation (and thus the
time until any compile errors are detected) is several times smaller
with ninja.

These numbers were measured with the benchmark.sh included in the
repository.

https://github.com/rabinv/kninja

I'm not posting the code as patches here since it's basically a hack.
It parses make's --print-data-base output and requires a full build to
have been performed with make before it can generate the ninja build
files. Configuration changes and various files with special generation
rules are not handled.

Perhaps it is useful for "personal use" or as inspiration for
optimizations to Kbuild.