MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

Compiling Firefox With Clang On Linux

Introduction

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

Advantages of using clang

  • Clang has a better compilation speed than gcc.
  • Clang usually provides 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.

Installing clang

Most of the GNU/Linux distributions are coming with a recent clang version. For example, under Debian or Ubuntu, the following command will install clang:

apt-get install clang
# or, to force a specific version of clang:
apt-get install clang-3.8 

The LLVM community is also proposing nightly Debian & Ubuntu package repositories of the most recent versions of clang

Under Mac OS X, clang is the default compiler shipped with Xcode.

In order to use clang instead of gcc, you should add the following two lines to your mozconfig file:

export CC=clang
export CXX=clang++
# or, force a specific version of clang:
export CC=clang-3.8
export CXX=clang++-3.8

For more information, check out this page.

References

Document Tags and Contributors

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