Using distcc and clang on Linux to build Firefox faster on MacOSX

Apple makes nice hardware, until you look into the details. As it turns out, my Macbook Pro has issues with heat. So much that when building Firefox, the CPU decides it’s too hot and throttles its frequency to emit less heat. The result is that building Firefox takes much more time than it would if the CPU could stay at its highest frequency all the time. On this machine, it takes more than an hour to build Firefox.

Most of the time, this MBP runs Linux. The heat problem is the same, but I also have a much beefier build server, running Linux too, that I use for builds. I used to use distcc from the MBP, using both the MBP and the build server to build everything. This was convenient, because the source tree could stay on the MBP. It however turned out to be slower than doing a local build on the build server. So I now push my changes to the build server, which then does the build alone. It takes about 18 minutes for a clobber build (without ccache), this way.

Anyways, I don’t build often on Windows or Mac, but when I need to, I’m essentially doing a clobber build, and as a result, the MBP spends an awful lot of time doing so. So, since I already had a distcc daemon running, with clang available, and since I was in need for a Mac build, I figured I’d try something seemingly crazy: use the Linux build server.

It turns out Linux clang is able to emit Mach-O objects (the binary format used on MacOSX). So all I needed to do was to add something like the following to my .mozconfig:

export CC="distcc clang -ccc-host-triple x86_64-apple-darwin"
export CXX="distcc clang++ -ccc-host-triple x86_64-apple-darwin"

(After fixing bug 818092)

Now I can enjoy builds taking slightly less than 30 minutes. Which is more than twice as fast.

Update: in case this wasn’t very clear, the build is initiated from OSX, where preprocessing is handled (distcc pump mode is not enabled), which allows the Linux build server to do the right thing with clang.

2012-12-04 19:30:15+0900


You can leave a response, or trackback from your own site.

One Response to “Using distcc and clang on Linux to build Firefox faster on MacOSX”

  1. Justin Dolske Says:

    Perhaps a good option for community folks, but as a Mozilla employee (right?) you should seriously talk with your manager about getting a beefier build machine. Hardware’s cheap compared to developer time! My recent MBP does a full clobber in < 15 minutes.

Leave a Reply