What is the difference between the different compilers
In the cocoa fundamentals documentary, it mentions about th开发者_Python百科e different compilers. The gcc, LLVM-GCC and Clang. Does anyone specifically know what they do and when to use them?
They all do the same thing, produce executable object code that can be linked together to build a program (or shared library). They just do it in different ways.
- gcc is a venerable old compiler of yore that is getting a bit long in the tooth, but is still the primary workhorse of virtually the entire open source world. It is also the most portable compiler in existence.
- LLVM-GCC is a component of the LLVM project that uses the gcc parser front end with the LLVM code-generation backend.
- Clang is an LLVM-specific front end that uses the LLVM back end. It is essentially a clean-room compiler that promises faster compiles producing more efficient code than gcc, all from a much smaller and cleaner code base (thanks @dreamlax).
Much more information on this is available on the LLVM site.
- gcc: GNU Compiler Collection. Very portable compilers for many different languages. Licensed under the GPL.
- LLVM-gcc: Uses the frontend of GCC to parse the program code but uses LLVM to generate machine code.
- Clang: New frontend for C-Like languages (C, C++, Objective-C) that uses LLVM to generate machine code.
Apple recommends you always use Clang. The main advantages of Clang are that it is faster and that it generates better diagnostic messages (warnings and errors). Also the generated code from clang is often faster than the one from GCC.
The version of Clang that is shipped with Xcode 3 doesn’t yet support C++ (or Objective-C++), so Xcode will use LLVM-GCC for C++.
Here is a more detailed comparison of Clang and GCC.
精彩评论