Clang is a new C-targeted compiler intended specifically to work on top of LLVM.
[8] The combination of clang and LLVM provides the majority of a toolchain, allowing the replacement of the whole GCC stack.
One of clang's primary goals is to better support incremental compilation to allow the compiler to be more tightly tied to the
IDE GUI. GCC is designed to work in a "classic" compile-link-debug cycle, and although it provides useful ways to support incremental and interrupted compiling on-the-fly, integrating them with other tools is not always easy. For instance, GCC uses a step called "fold" that is key to the overall compile process, which has the side effect of translating the code tree into a form that does not look very much like the original source code. If an error is found during or after the fold step, it can be difficult to translate that back into a single location in the original source. Additionally, vendors using the GCC stack within IDEs used separate tools to index the code to provide features like
syntax highlighting and
autocomplete.
Clang is designed to retain more information during the compilation process than GCC, and preserve the overall form of the original code. The objective of this is to make it easier to map errors back into the original source. The error reports offered by Clang are also aimed to be more detailed and specific, as well as machine-readable, so IDEs can index the output of the compiler during compilation. Since the compiler is always running, it can offer
source code indexing, syntax checking, and other features normally associated with
rapid application development systems[
vague]. The
parse tree is also more suitable for supporting automated
code refactoring, as it remains in a parsable text form at all times. Changes to the compiler can be checked by
diffing the IF.
GCC systems don't support threading at the single compilation level and cannot take advantage of the multi-processor hardware for single compilation units. Clang was designed from the start to be threaded and aims for reduced memory footprint and increased speed. As of October 2007, clang compiled the
Carbon libraries well over twice as fast as GCC, while using about five times less memory and disk space.
[10]
Although development on GCC may be difficult, the reasons for this have been well explored by its developers. This allowed the clang team to avoid these problems and make a more flexible system. Clang is highly modularized, based almost entirely on replaceable link-time libraries as opposed to source code modules that are combined at compile time, and well documented. This makes it much easier for new developers to get up to speed in clang and add to the project. In some cases the libraries are provided in several versions that can be swapped out at runtime; for instance the
parser comes with a version that offers performance measurement of the compile process.