With the imminent launch of the Raspberry Pi 5 I wondered - how long does it take to compile the latest LLVM release (17 at the time of writing this blog) on the Raspberry Pi 4. This will give me a baseline that I can test the Raspberry Pi 5 against once I get ahold of it.
For my initial exploration I decided to test just three things:
- Using the stock Clang compiler I could get at via
apt getto compile LLVM. This is Clang 11 at the time of writing this post.
- Use the Clang 17 compiler built above to compile LLVM itself again. This stage will mean that the LLVM code itself is being built with the latest compiler.
- Then use the stage 2 compiler to compile LLVM a third time. This will test whether the Clang 17 compiler built by the Clang 17 compiler is more optimal.
I decided to just build with
CMAKE_BUILD_TYPE=RELEASE, and I decided to build
the Bolt, Clang, LLD, and compiler-rt subprojects. Just to keep it simple but
So what are the results?
First lets look at the time taken:
As can be seen in the chart it takes a cool 9.52 hours to build with the stock Clang 11 compiler. First observation - wow that’s a long time! But the Clang 17 compiler we built with Clang 11 goes a cool 12.9% faster, coming in at 8.42 hours. The Clang 17 compiler built with Clang 17 would reliably run a smidge faster at 13.3% faster than Clang 11, coming in at 8.40 hours.
And now the binary size of Clang too:
The binary size of the compiler built with Clang 17 was identical in both cases, which is as expected (it’d only differ if there was a compiler bug or some sort of non-deterministic behaviour in the compiler). The binary built with Clang 17 is 15.3% larger than the binary built with Clang 11.
Overall this result shows that Clang 17 is faster than Clang 11, but it is achieving this in part with a sizable increase in binary size.
It’ll be interesting to see how the Raspberry Pi 5 compares in comparison once I can test it!