20

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?

Evgeni Sergeev
  • 22,495
  • 17
  • 107
  • 124

1 Answers1

21

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.

Oak
  • 26,231
  • 8
  • 93
  • 152
  • Somewhere I've read that the pre-built binary targets Visual Studio in some ways, and indeed, trying it, (and specifying system include paths with `isystem` as described [here](http://stackoverflow.com/a/17104069/1143274) `$ clang++ -std=c++11 -isystem /usr/local/include -isystem /mingw/lib/gcc/mingw32/4.8.1/include/c++ -isystem /mingw/lib/gcc/mingw32/4.8.1/include/c++/mingw32/ -isystem /mingw/lib/gcc/mingw32/4.8.1/include/c++/backward/ -isystem /mingw/include/ -isystem /mingw/lib/gcc/mingw32/4.8.1/include -isystem /mingw/lib/gcc/mingw32/4.8.1/include-fixed/ b.cpp`, I get: – Evgeni Sergeev Feb 14 '14 at 23:34
  • 1
    ... `C:/m/lib/gcc/mingw32/4.8.1/include\x86intrin.h:27: C:/m/lib/gcc/mingw32/4.8.1/include\ia32intrin.h:41:10: error: use of undeclared identifier '__builtin_ia32_bsrsi' return __builtin_ia32_bsrsi (__X);` – Evgeni Sergeev Feb 14 '14 at 23:35
  • Not much luck trying to `make` either the latest SVN version or the latest release, 3.4, under MinGW/MSYS: I get `llvm/lib/Support/Windows/Process.inc:366:32: error: 'rand_s' was not declared in this scope`. So giving up for now, because while I'm sure I could get it to work on my system after some troubleshooting, it has to be easy enough for others to do in under 10 easy steps, and also be future-proof, for the suggestions notes that I'm going to distribute. – Evgeni Sergeev Feb 14 '14 at 23:49
  • Oh yeah, also tried downloading `i686-w64-mingw32-clang-3.2-release-win32_rubenvb.7z` from http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.2-release/ (which has the `w64` in it, but runs under both 32 and 64 bit versions) but *that* `clang++` segfaults and, running it under `gdb`, the stack trace doesn't show anything obvious. – Evgeni Sergeev Feb 14 '14 at 23:54
  • @EvgeniSergeev I'm afraid I don't know how to help you... you should open another question about these problems (or ask on the LLVM-dev mailing list). – Oak Feb 15 '14 at 08:00