mozilla

Revision 448571 of Compiling Firefox With Clang On Linux

  • Revision slug: Compiling_Firefox_With_Clang_On_Linux
  • Revision title: Compiling Firefox With Clang On Linux
  • Revision id: 448571
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Editorial review

Revision Content

Introduction

Clang is a new C/C++/Objective-C/Objectice-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.

mkdir /path/to/clang-build
cd /path/to/clang-build
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
mkdir build
cd build
../llvm/configure --enable-optimized --disable-assertions
make && sudo make install

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.

References

Revision Source

<h2 id="Introduction">Introduction</h2>
<p><a href="http://clang.llvm.org/">Clang</a> is a new C/C++/Objective-C/Objectice-C++ compiler being developed on top of <a href="http://llvm.org/">LLVM</a>.</p>
<h2 id="Advantage_of_using_clang">Advantages of using clang</h2>
<ul>
  <li>Clang has much better compilation speed than gcc.</li>
  <li>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.</li>
</ul>
<p>Check out <a href="http://clang.llvm.org/diagnostics.html" title="http://clang.llvm.org/diagnostics.html">this page</a> for more reasons why clang provides better compiler diagnotics.</p>
<h2 id="Building_and_Installing_clang">Building and Installing clang</h2>
<p>The following steps work on Mac and Linux only. Note that the clang port is not ready for everyday use yet, so I&nbsp;won’t recommend you switching to clang if you’re on Windows.</p>
<pre lang="bash">
mkdir /path/to/clang-build
cd /path/to/clang-build
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
mkdir build
cd build
../llvm/configure --enable-optimized --disable-assertions
make &amp;&amp; sudo make install</pre>
<p>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:</p>
<pre lang="bash">
export CC=clang
export CXX=clang++</pre>
<p>For more information, check out <a href="http://clang.llvm.org/get_started.html" title="http://clang.llvm.org/get_started.html">this page</a>.</p>
<h2 id="References">References</h2>
<ul>
  <li><a href="http://ehsanakhgari.org/blog/2011-10-18/why-you-should-switch-clang-today-and-how" title="http://ehsanakhgari.org/blog/2011-10-18/why-you-should-switch-clang-today-and-how">http://ehsanakhgari.org/blog/2011-10-18/why-you-should-switch-clang-today-and-how</a></li>
</ul>
Revert to this revision