Over a million developers have joined DZone.

LLVM's Clang Compiler Achieves Self-Hosting

DZone 's Guide to

LLVM's Clang Compiler Achieves Self-Hosting

· Java Zone ·
Free Resource
Self-sufficiency is a major milestone for any compiler technology.  The LLVM (Low Level Virtual Machine) developers were pleased to announce that their open source compiler, named Clang, has just reached this milestone.  Clang recently completed its first complete self-host by building all of the LLVM and itself.

In the testing process, Clang was able to compile over 550,000 lines of C++ code, which is the total amount of lines in LLVM and Clang.  The resulting binaries passed all of the regression test suites for Clang and LLVM.  The self-built Clang was then able to build the 550k lines LLVM and Clang code again.  The third Clang build was also fully-functional, which made the bootstrap complete.

Clang is a new front-end for the LLVM that was started several years ago.  The developers' goal is to build a compiler that provides better diagnostics, tighter integration with IDEs, and a license that is compatible with commercial products.  The LLVM team wants a more lightweight compiler in Clang that is easy to develop and maintain.  They say that Clang is great for source analysis or source-to-source transformation.  However, full support for C++ is "still way off," according to the website.

                                 Quick-n-dirty performance test results for template instantiation by Douglas Gregor

LLVM got a little extra attention back in October of last year when Adobe announced (at Adobe MAX) that Flash CS5 would be able to use the LLVM compiler infrastructure along with an ActionScript 3 reading front end to build iPhone compatible Flash apps.  Apple and Adobe both support the LLVM project, which was started in 2000 at the University of Illinois.  The LLVM is a virtual machine and compilation system that enables optimization of intermediate code at compile, link, and runtime.  The project initially focused on working with C/C++ code, but the project's community has since developed front-ends for Java byte code, Python, Ruby, ActionScript 3 (as mentioned before), and Microsoft's CIL.

Take a look at the comparisons between Clang and other compilers on their website.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}