Clang Leads Firefox Compile Times on Linux

Windows build sadness aside, as I went back to my old standby, Linux, I started to wonder about its build times. Am I doing my absolute best here? Lets do some tests. I’ve been using Clang ever since I need to do asan builds — yeah, yeah I know GCC supports this as of version xyz, but I also get fun things like our static analysis plug-in and pretty error messages.

GCC vs Clang
The buildening: there can be only one

As an aside: to install Clang I just downloaded the x86_64 Ubuntu build from LLVM’s official site. Nice and easy. For GCC builds go to the gcc site, check out their sweet binaries page where they let you know you can build it yourself you filthy animal and if you’d please download the source from a mirror that’d be great. If we’re evaluating on website alone GCC has already lost.

So the results of doing clean builds, no ccache:

Compiler Clobber build time
clang-3.9.0 18 min
gcc-5.4.0 21 min
gcc-6.3.0 22 min

Build system specs: Ubuntu 16.04 LTS, 8 core Intel Core i7-4770 CPU @ 3.40GHz, 32 GB RAM, SSD, example of .mozconfig used.

Why those versions? I was already using clang 3.9.0 (and it was the latest release at the time), gcc 5.4.0 is what ships with Ubuntu 16.04, gcc 6.3.0 is the latest release.

Now you may argue that the resulting executable of foo bar baz is going to be smaller/faster/better. And I’d argue as a dev I don’t care. I just want to build quickly so I can run my test and repro a bug. Generally speaking all my builds are debug, asan-enabled, dmd-enabled. They’re never going to run fast.

I’d love to hear your thoughts on how to get optimal build times of Firefox on all platforms. Maybe I can build with better settings — for GCC I just used a vanilla config I found on another blog. I tried doing a PGO build of clang trained on building Firefox, but I ended up getting worse times with that. Odds are I was doing it wrong, but it would be pretty cool if Mozilla could produce them in our build infrastructure; I filed bug 1326486 for this.

It would be interesting to see the gcc and llvm folks use our codebase as a testing ground for build time performance — maybe it’s time to fire up arewecompiledyet.com.

4 thoughts on “Clang Leads Firefox Compile Times on Linux”

  1. And I’d argue as a dev I don’t care.

    I’m also a dev and I’ll argue the same, but I’ll also argue that I don’t care about build times with optimizations enabled. So are your numbers for debug or release builds? In my experience, GCC is slightly slower than clang with optimizations enabled, and with debugging flags they are about the same. (and GCC compiles about factor 2.5 faster without optimizations but that heavily depends on the project.)

  2. I’m actually surprised that the difference with clang is only a couple of minutes – they used to be dramatically faster than GCC.

Leave a Reply

Your email address will not be published. Required fields are marked *