Faster Clang

20 Jun 2018

Sticky notes on speeding up Clang builds and rebuilds. Expect a lot of edits.

The first issue is that Makefiles generated by CMake don’t always incldue header information. Not to mention C++ can recursively add in headers.

clang++ -H hello.cpp

That will list all the headers.

I couldn’t get to work. First you have to use gtime under OSX and sed needs different flags

sed -i 'something' #Linux
sed -i -e 'something' #OSX

Here is what I ended up using, call this file rusage_cpp.

exec gtime -f '%e (elapsed)   rc=%x elapsed=%e user=%U system=%S maxrss=%M avgrss=%t ins=%I outs=%O minflt=%R majflt=%F swaps=%W avgmem=%K avgdata=%D argv="%C"' clang++ -H   "$@"
cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/rusage_cpp 

Next what about those headers? Clang supports precompiling them

Next, some sort of caching of objecy files