Compiling Firefox With Clang On Linux


Clang is a new C/C++/Objective-C/Objective-C++ compiler being developed on top of LLVM.

Advantages of using clang

  • Clang has much better compilation speed than gcc.
  • Clang usually provides much better diagnostics in case your code fails to compile, which means that you need to spend less time trying to understand what you should do to fix your code. It even goes further by suggesting the most likely fixes.

Check out this page for more reasons why clang provides better compiler diagnotics.

Building and Installing clang

The following steps work on Mac and Linux only. Note that the clang port is not ready for everyday use yet, so I won’t recommend you switching to clang if you’re on Windows. As of November 2013, the trunk of clang is unsuited for building Firefox. The 3.3 release works. (The release page has links to GPG signatures for the files downloaded in the guide below.)

mkdir /path/to/clang-build
cd /path/to/clang-build
tar zxvf llvm-3.3.src.tar.gz
mv llvm-3.3.src llvm
cd llvm/tools
tar zxvf cfe-3.3.src.tar.gz
mv cfe-3.3.src clang
cd ../..
mkdir build
cd build
../llvm/configure --enable-optimized --disable-assertions

Finally, you need to either run

 sudo make install

or on Linux, you probably want to create a removable package instead:

 sudo checkinstall --pkgname clang --pkgversion 3.3 --nodoc -y

At this point, clang should be installed to /usr/local. In order to use it, you should add the following two lines to your mozconfig file:

export CC=clang
export CXX=clang++

For more information, check out this page.


Document Tags and Contributors

 Contributors to this page: teoli, mdnpali, kafene, Hsivonen, kscarfone, sawrubh
 Last updated by: mdnpali,