Improving Compilation Time of C/C++ Projects | Interrupt

We’ve all likely worked on a software or firmware project where the build takes a “coffee break” amount of time to complete. It’s become such a common occurrence that there is an infamous xkcd comic related to the matter.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/improving-compilation-times-c-cpp-projects
1 Like

Nice.
Small tweak:
find . -name "*.i" | xargs wc -l | sort -r

should probably be:
find . -name "*.i" | xargs wc -l | sort -rn

Note the -n

Regarding developer hardware: These days I see no reason to settle for anything less than 8 cores (actually, machines with 8 cores are labeled “slow” in our CI system).

Good catch. Will make an edit. Thanks!

Clang has a -ftime-trace option that is really handy for this. It generates dumps that can be read by Chrom{e,ium}'s about:tracing.

That’s really cool! After some searching around, it looks like there is also some work underway to do the same for GCC. 92396 – -ftime-trace support

Is it possible to compile 1gb file with gcc with system ram 4g in a day

I don’t see why not. What is your concern?