Switched to Clang

06 Dec 2011 - mozilla

A recent conversation in #devtools

<nigelb> My current build segfaults when I touch the webconsole.
<robcee> that's no good
<nigelb> That's counter productive when I'm patching the webconsole.
<robcee> are you on linux?
<nigelb> Ya.
<robcee> are you building with clang?
<nigelb> No I'm not.
<nigelb> gcc forever <3
a little while later
<nigelb> Wait, that's a gcc bug?
<msucan> yes
<nigelb> Sadness.
<nigelb> gcc </3
<nigelb> its time to move on.
<robcee> it was a good run

So, yeah, I’ve switched to clang on Ubuntu. A quick rundown of what I did for any Ubuntu or other Linux users. The instructions are pretty much the same as what ehsan posted for Mac, except I didn’t install clang system-wide.

So, here’s what I did.

mkdir clang
cd clang
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

This got the clang binary in Release/bin. I use ZSH, so I added that folder to my $PATH variable like so

export PATH=$PATH:$HOME/clang/build/Release/bin

The last bit is to add the following to your .mozconf

export CC=clang
export CXX=clang++

Note - If you’re working on Ubuntu 10.04 with gcc version 4:4.4.3–1ubuntu1, it might be essential to use clang and not gcc. As of now the segfaults are attributed to gcc. For more details, see bug 694594