What are the pros and cons of GCC vs clang/LLVM?

  • 3
    Pros/Cons for whom? LLVM is clearly superior as backend for compilers, except if you require a ridiculous amount of supported architectures. But I assume you're talking about end users.
    – user7043
    Commented Apr 22, 2011 at 22:52
  • 1
    Closing questions like these is asinine, and is a massively missed opportunity for Stack Exchange sites like this to host really valuable and insightful content which stays up-to-date--a kind of wikipedia of sorts for programmers. Commented May 1, 2020 at 21:59
  • 1
    Related: Clang vs GCC for my Linux Development project Commented May 1, 2020 at 22:01

4 Answers 4


gcc is very mature, easy to install (at least for most systems), and is the default compiler for lots of systems so in many cases people have it installed almost without even realizing it. Its been ported to a zillion architectures, so it's much more likely to work out of the box if you have to target obscure hardware.

clang is much newer. It frequently produces much better error messages, especially for C++ templates. In many cases, it runs a lot faster. It's built primarily as a set of libraries, so there are quite a few other projects (e.g., code analyzers) that use the same front-end, understand the same inputs, etc. Using llvm as its back end gives it some extra flexibility in how you generate code from it.

  1. Clang has much better error reporting. E.g. if you make a typo in a function name you call, Clang will report that this is likely a typo (and suggest the correct name), while GCC will complain about unknown function name.

  2. GCC usually produces faster code if you target x86/x86-64. For ARM the situation is ambiguous, often Clang optimizes better. Also, AFAIK Clang does not support optimization for code size.

  3. GCC uses a lot of heuristics. This is good for performance (in a typical case), but awful if you want to do some source-level optimization (e.g. loop unrolling). Even small source code changes can make GCC generate a completely different output. Clang is more predictable, and usually it generates the code you expect.

  4. Unlike Jerry Coffin, I find building GCC from source much harder than Clang. The procedure from Clang's Getting Started page always worked for me. Similar manual for GCC never worked in the first try. GCC has dependencies on particular versions of GMP, MPFR, MPC, Parma Polyhedra Library, and CLooG, and I needed several iterations to find the versions which would work for a particular GCC release (yes, using the latest versions of those libraries does not work).

  5. I have a feeling that Clang is better tested than GCC. Even though I only use official releases of GCC, it sometimes produced faulty code. For Clang I usually use the trunk version (again, because it is easy to build), but I never saw it generating wrong output.

  6. GCC is nearly standard in Linux world, and it adds a lot of non-standard features which are widely used in Linux software. Clang tries to be compatible with GCC, but sometimes it just quietly ignores them. Most importantly, Clang does not support OpenMP. However, it also has extensions which are not supported by GCC, but can be useful (e.g. add-with-carry intrinsic functions __buildin_addc).

  7. If you want to do compiler research, or just curious about how it works, you will find Clang/LLVM source code more accessible. Clang/LLVM code is human-readable, not just compiler-readable.

  8. (AINAL declaimer applies) Clang/LLVM license gives you more freedom about what you can do with the code, e.g. use in commercial or closed-source product. License for GCC runtime libraries adds another layer of restrictions while Clang compiler runtime (compiler-rt library) is under permissive MIT license.

Summary: compile with Clang when you develop the program, and with GCC for the final build (but make sure that its faster and doesn't break). Stick with Clang/LLVM if you do compiler research.

  • Interesting, I've never known that Clang has add-with-carry intrinsic. But it should be __builtin_add, not __buildin_addc. Anyway, Clang is smart enough to generate addc when it encounter a wide add using comparison as carry
    – phuclv
    Commented Mar 12, 2015 at 8:38
  • I mean __builtin_addc not __buildin_addc
    – phuclv
    Commented Mar 19, 2015 at 9:10
  • Performance comparisons here are out of date. According to more recent benchmarks, clang is faster than gcc on x86/64 in slightly over half tests (e.g. openbenchmarking.org/result/1605071-HA-GCCCLANG568)
    – Jules
    Commented Jun 10, 2016 at 7:32

If you have a new CPU architecture or new optimizations, and want to open source them under the GPL, you can contribute them to gcc. However, gcc is less modular, so this may involve more work to add one's modifications/additions. If you want to contribute new architectures or optimizations to an open source project, but under a non-GPL license, you can contribute them to the LLVM/clang. There exist corporations whose legal departments only allow the latter.


Today (8/11/2011), GCC supports a lot more of the C++0x features than Clang does. If you want those features, it's a no-brainer; GCC is your option.

  • 1
    This answer is accurate and informative within the time frame specified according to my research.
    – user54262
    Commented May 17, 2012 at 7:35
  • 8
    But is not a very good answer really, because as of today (28/07/2012) it's point is no longer valid. Clang supports more than GCC, if anything.
    – DeadMG
    Commented Jul 28, 2012 at 1:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.