delphij's Chaos

选择chaos这个词是因为~~实在很难找到一个更合适的词来形容这儿了……

29 Jan 2009

Progress on LLVM clang

As some of you already know, FreeBSD, along with some other Open Source projects, is moving away from GCC due to GPLv3. From a technology perspective, this also makes sense since the (likely) candidate, BSD-style licensed, LLVM based clang, a C compiler, is making reasonably good progress.

So, what should we expect from LLVM or clang?

Here is a good comparison between GCC and clang. Despite GCC is popular, considerably more mature, and supports more languages (especially C++, which clang’s support is incomplete at this moment), clang provides cleaner AST (Abstract Syntax Tree), much more modularized (if you take a look at GCC’s history, Richard Stallman intentionally made GCC’s code not reusable in other software), provided much more information for optimizer, is much faster and use much less memory, etc.

For FreeBSD, currently, clang can compile its kernel with only very few tweaks.

Why yet another compiler is so important?

First off, LLVM provided a very nice infrastructure that is being used by a wide variety of applications, including open source and closed-source commercial product. Being exercised by various parties, the code would get mature more faster, and more likely, bugs are being found and fixed fast. LLVM and clang has been supported by companies that uses it, giving full time developers and code back to the project.

Moreover, the design decision of LLVM/clang is technology oriented, giving it better chance to survive in complex optimization scenarios, and the clean design means it is much easier to debug the compiler toolchain itself, and the compiler can run faster.

The final point. As an Open Source project, for FreeBSD itself, GPLv3 does not actually limit our ability to publish our code. However, adopting GPLv3 code into the base system, may cause problems for users who does not wish to be encumbered by the license terms. We believe that giving the user more choices would be beneficial.