

LLVM's Clang Successfully Self-Hosts - yan
http://blog.llvm.org/2010/02/clang-successfully-self-hosts.html

======
spicyj
So did the third compilation produce a binary identical to that of the second
one?

~~~
derefr
It would be awesome if there were some sort of Trusting-Trust-style
"telomeres" encoded into the resultant binary, so that C and C' and C'' would
all work identically, but C'''''''''' would suddenly produce different
outputs.

~~~
eru
And of course they should be invisible in the source after the first go.

~~~
sp332
He means taking the source code for the compiler and running it through the
compiler, then taking the _same_ source code and running it through the
resulting compiler, etc. Same source, new binaries every time.

~~~
eru
Yes. I know "Trusting trust". And the backdoor will be in the original source
code, and after it has passed into the binary you get rid of it in the source.

------
jeff18
Wait does this mean that LLVM supports C++ well now? Last time I checked at
WWDC, it had great C and Objective-C support, but C++ was hardly there. It
would be great if Xcode can add support for all of the awesome refactoring and
static analysis that Objective-C can currently do in C++ now!

~~~
bryansum
Looks like there's still a lot of work to be done:
<http://clang.llvm.org/cxx_status.html>

~~~
gane5h
In my opinion, I believe llvm-g++ is a more promising approach to supporting
C++. C++ is an incredibly difficult language to parse, so why not re-use work
that has already been done?

~~~
pieter
Because g++ has its own problems that won't be solved by switching backends,
like unclear diagnostics. Then there's the license issue, which can be
important for some. Clang is also built as a library, so you can link to it
and JIT c-code at runtime.

------
Locke1689
Big step, congratulations to everyone who worked on it. When I get some more
time I need to look into the code in those projects. It's too bad that they
chose to use C++ (as opposed to C) to implement it though (yech, personal
preference).

~~~
jey
It's truly excellently written C++ code, and they don't go nuts with fancy C++
voodoo template meta-trans-factory-programming tricks or whatnot. And have you
seen what happens when you write a huge compiler in C? This:
<http://gcc.gnu.org/wiki/reload> And I don't think you can reasonably argue
that GCC's hackers are sub-par either. ;-)

Language features for abstraction and encapsulation are pretty important for
something that huge.

~~~
krakensden
I'd argue that there is an age factor at play- GCC is older, designed under
different (ie, much more stringent with regards to resources) constraints.

GCC also has a perennial problem attracting and managing developers, which
LLVM seems to have avoided.

~~~
jey
It's really not the age or resources that hamper it (from experience hacking
it). Well, OK, the age _does_ matter -- but only because it's C. It wouldn't
have been so bad if they didn't have to reinvent basic things. GCC has its own
garbage collector, a set of bizzare hacks to replace inheritance, amongst
other atrocities. None of these have to do with resource constraints, and
nearly all have to do with the low-level nature of C.

------
snowbird122
Will someone please explain what this means.

~~~
spicyj
Clang, a new compiler based on LLVM (<http://llvm.org/>), designed to be
faster and more extensible than GCC, is now able to build its own source tree
rather than relying on another compiler. This means that the compiler supports
a sizable chunk of C/C++ language features.

~~~
raintrees
Thank you. That was way too self-referential for me to follow, as well.

~~~
by
C programmers often use the free GCC (GNU compiler collection) to compile
their programs. clang is a new open source C compiler that may be better for
some people because it has a different licence, will be faster in certain
circumstances and may give better error messages. The significant milestone
the clang project has reached is the ability to sucessfully compile a very
large quantity of C code.

(Edit: C++ as well as C)

~~~
utku_karatas2
> because it has a different licence

In which manner does the GCC license restrict the user in a problematic way?
(well, except GPL's distribution restrictions I suppose.)

~~~
alextgordon
Clang and LLVM take a library based approach. They're designed so that tools
that need to work with C/C++/Objective-C can simply link Clang.

GCC was never designed to do this, and even if it were, it's under the GPL and
not the LGPL, which makes it unsuitable for linking as a library in non-GPL'd
code. In contrast LLVM/Clang has a BSD-like licence.

~~~
protomyth
To add, the use of the less restrictive license allows the creation of tools
using clang like a library. For example, you can now use the same parser the
compiler is using to do syntax highlighting or refactoring. This will allow
both commercial / non-commercial interests to build tools that do interesting
things without having to build a parallel infrastructure.

------
c00p3r
Is it already imported into FreeBSD as a default system compiler? =)

