Clang and LLVM - Release vs Debug builds

Evgeni Sergeev picture Evgeni Sergeev · Feb 8, 2014 · Viewed 20.3k times · Source

It seems like a simple question, but it's taking a lot of time to figure out...

In the instructions for building LLVM+Clang, a Release and a Debug configurations are mentioned. Is the debug version for:

  • Debugging LLVM/Clang itself,

OR

  • Debugging the application that you're trying to build with Clang+LLVM?

I initially assumed the former, but then (1) it is the default, (2) I found multiple sets of instructions around, which direct us to build the Debug mode, (3) while I'm assuming that it would be of interest to a relatively tiny proportion of users — most will want to use Clang+LLVM, not delve into the intricacies of optimising compiler design.

I'm planning only to use Clang in place of GCC to take advantage of, from what I've heard, better error messages, but I will need to debug the programs it produces under GDB. Is a Release version of Clang enough for that?

(Note that the Debug version is a few GB and will probably take a long time to build, so I'd rather find out the easy way.)

Plus, on that same page, it says I should specify ONLY_TOOLS="tools you need", but where is a list to choose from?

Answer

Oak picture Oak · Feb 8, 2014

The former is correct - you only need to build LLVM and Clang in debug mode if you want to debug the compiler. If you want to debug the application produced, you need to compile it with debug symbols - i.e. pass the -g flag to Clang when you build your program - and that is enabled no matter in what mode LLVM and Clang were built.

So for your needs, you should compile in release mode.

As for your question - why is that the default - I'm guessing it's because it is assumed that if you wanted to just run it, you'd just obtain a pre-built binary instead of downloading and building the source code.

Also, regarding that last question you sneaked in - I believe it is referring to tools from this list of LLVM tools.