The Bleeding Edge: A New Frontier - Clangalang Clang Clang BSD!
Just announced: Clang is self hosting! it can compile the FreeBSD World, and to quote a David Bowie song of yonder years, it is, "...stepping through the door", of new possibilities.
Possibilities that not only endear it to the community of early adopters and voracious testers, but also the doorstep of becoming it's own 'Flavor' of UNIX - ClangBSD...
What is Clang? LLVM? and ClangBSD?
LLVM, the Low-Level Virtual Machine compiler infrastructure, capable of offline optimizations (after the software has been installed), and a standalone compiler in its own right, LLVM doesn't require garbage collection or generation of runtime code, and has a modular approach to front end processors - like Clang.
Clang (pronounced, "See-Lang"), is a front end for LLVM, which focuses on C, bringing the capabilities of a 'new heart' to a BSD UNIX system.
Clang's emphasis and goals are different from the standard GCC compiler, and although at this point it lags, development wise, somewhat behind in maturity in the support of C++, some of its comparative differences by design can be summarized below:
- Clang support is for C and C++, leaving other front ends to deal with support for languages such as FORTRAN, Ada, and Java.
- Clang uses much less memory and is way faster than GCC
- GCC is a static, monolithic compiler that in most circumstances cannot be decoupled as a front end, while Clang is built from the ground up as an API.
- Clang inherently uses expressive, 'Caret Diagnostics'. For example, even inside of strings, Clang is capable of pinpointing the exact location of mistakes.
The goal of ClangBSD, as a branch of FreeBSD, is to replace GCC as the system compiler. These may seem like grandiose goals, but nevertheless a goal that according to today's announcement at FreeBSD.org by Roman Divacky is within reach very shortly.
At the current time, the Clang team is asking volunteer testers and early adopters to install Clang, not into root, but a chroot, since there hasn't been enough widespread testing by all of the elbow-checkers out there.
Even so, The team confident enough to ask that people install and use FreeBSD as one normally would - a sign that we may soon see a new UNIX flavor forking completely from FreeBSD, with a faster, more modular and powerful system compiler - something that really hasn't appeared on the landscape since Linux first burst onto the scene in 1991.
In a nutshell, here's the quick, down and dirties from today's announcement for getting ClangBSD off and sprinting:
svn co http://svn.freebsd.org/base/projects/clangbsd/ clangbsd
cd clangbsd && make buildworld
echo NO_WERROR= >> /etc/make.conf
echo WERROR= >> /etc/make.conf
make DESTDIR=/clangbsd-chroot/ installworld
At this point you have the ClangBSD world installed and chroot into it, and Clang is mature enough at this point to install and run a Clang compiled kernel, either by setting CC to clang and then doing the kernel build, or in the ClangBSD chroot by setting 'NO_WERROR=yo and WERROR=yo in /etc/src.conf'.
This is a really kewl, if not downright revolutionary thang people. Considering all of the additional tools and features working in conjunction with ClangBSD, we may expect to see clang displace, indeed obviate, GCC. In the future we may either be offered a choice of system compilers during installation, or clang might just wind up as the default system compiler in BSD and Linux Unices!
More in depth information can be found on the "FreeBSD Wiki