Xcode 3.2.1 GCC CLANG和LLVM解构

时间:2021-07-13 02:23:57

The readme included with the new Xcode 3.2.1 this week says the following:

这周的新Xcode 3.2.1包含了readme:

  • Static code analysis is fully integrated within the Xcode IDE via the Build and Analyze option under the Build menu or via custom build settings
  • 静态代码分析通过构建菜单下的Build and Analyze选项或自定义构建设置完全集成在Xcode IDE中
  • GCC 4.2 is the default system compiler for the 10.6 SDK
  • GCC 4.2是10.6 SDK的默认系统编译器
  • The optional LLVM compiler is included using two different front ends - the Clang compiler is a leading-edge parser that offers dramatically improved compile times. For maximum compatibility, the GCC LLVM compiler utilizes the LLVM back-end with the GCC 4.2 parser.
  • 可选的LLVM编译器包括使用两个不同的前端——Clang编译器是一个前沿的解析器,提供了显著改进的编译时间。为了最大程度的兼容性,GCC LLVM编译器使用LLVM后端和GCC 4.2解析器。
  • New optional Clang-LLVM 1.0 compiler uses the much faster Clang front-end parser coupled with the LLVM back-end compiler for fast compiles and fast executable code. Many projects will benefit from this compiler combination, although GCC 4.2 is still the system default. The Clang-LLVM 1.0 compiler will fall back to using LLVM-GCC 4.2 when it encounters C++ code.
  • 新的可选的Clang-LLVM 1.0编译器使用更快的Clang前端解析器和LLVM后端编译器来进行快速编译和快速可执行代码。许多项目将从这个编译器组合中受益,尽管GCC 4.2仍然是系统默认值。当遇到c++代码时,Clang-LLVM 1.0编译器将退回到使用LLVM-GCC 4.2。

Our company has existing projects that are pure C, Objective-C, and Objective-C++ for desktop and iphone. Can someone summarize at a high-level the differences between LLVM, GCC, CLANG, CLANG-LLVM, WordFoo et. al. and explain what they are and when we should be using each and for what? It would be nice to have links to more a detailed explanation, but I'm really just looking for a high-level overview.

我们公司现有的项目都是纯C、Objective-C和objective - c++的桌面和iphone。有人能在高层上总结一下LLVM、GCC、CLANG、CLANG-LLVM、WordFoo等之间的差异吗?如果能有更多详细解释的链接,那就太好了,但我只是在寻找一个高层次的概述。

1 个解决方案

#1


53  

In a nutshell:

简而言之:

Compilers are basically split into two parts. One being the front-end that contains the parser and semantic analysis for the programming language. The front-end produces some kind of intermediate representation of your code. Then there's the backend which takes the stuff the front-end produced, optimizes it, and eventually generates assembly code.

编译器基本上分为两部分。一个是前端,包含编程语言的解析器和语义分析。前端产生某种类型的中间代码表示。然后是后端,将前端生成的东西进行优化,最终生成汇编代码。

  • GCC: well known compiler, contains both front-ends for various languages and back-ends for many processor architectures
  • GCC:众所周知的编译器,包含各种语言的前端和许多处理器体系结构的后端
  • LLVM: a set of back-ends for various architectures (and other low-level stuff)
  • LLVM:各种体系结构(以及其他底层内容)的一组后端
  • clang: a new front-end for C, Objective-C, and C++; uses the LLVM back-ends. You'll get more readable errors and warnings from your compiler and shorter compile times. You might also encounter incompatibilities or bugs; clang is a very young project.
  • clang: C、Objective-C和c++的新前端;使用LLVM后端。您将从编译器获得更多可读的错误和警告,以及更短的编译时间。您可能还会遇到不兼容或bug;clang是一个非常年轻的项目。
  • LLVM-GCC: GCC's front-end with LLVM's back-end. LLVM's back-end is faster than GCC's.
  • LLVM-GCC: GCC前端与LLVM的后端。LLVM的后端速度比GCC快。

clang's (Objective-)C++ support is far from being complete so it calls llvm-gcc when it encounters a C++ source file. It also contains the static analyzer that is now integrated into Xcode. Some people say LLVM's back-end generates better code than GCC's but your mileage may vary. LLVM also supports link-time optimizations (which you can enable in Xcode's project settings). They may produce faster code.

clang (Objective-) c++支持还远没有完成,所以当遇到c++源文件时,它会调用llvm-gcc。它还包含现在集成到Xcode中的静态分析器。有些人说LLVM的后端生成的代码比GCC的要好,但是您的里数可能不同。LLVM还支持链接时间优化(可以在Xcode的项目设置中启用)。它们可以生成更快的代码。

Apple wants to replace GCC with clang in the future because they have a policy against GPLv3 licensed code (GCC 4.2 is the last version that's licensed under GPLv2).

苹果公司希望在未来用clang取代GCC,因为他们有针对GPLv3授权代码的策略(GCC 4.2是在GPLv2下获得许可的最后一个版本)。

#1


53  

In a nutshell:

简而言之:

Compilers are basically split into two parts. One being the front-end that contains the parser and semantic analysis for the programming language. The front-end produces some kind of intermediate representation of your code. Then there's the backend which takes the stuff the front-end produced, optimizes it, and eventually generates assembly code.

编译器基本上分为两部分。一个是前端,包含编程语言的解析器和语义分析。前端产生某种类型的中间代码表示。然后是后端,将前端生成的东西进行优化,最终生成汇编代码。

  • GCC: well known compiler, contains both front-ends for various languages and back-ends for many processor architectures
  • GCC:众所周知的编译器,包含各种语言的前端和许多处理器体系结构的后端
  • LLVM: a set of back-ends for various architectures (and other low-level stuff)
  • LLVM:各种体系结构(以及其他底层内容)的一组后端
  • clang: a new front-end for C, Objective-C, and C++; uses the LLVM back-ends. You'll get more readable errors and warnings from your compiler and shorter compile times. You might also encounter incompatibilities or bugs; clang is a very young project.
  • clang: C、Objective-C和c++的新前端;使用LLVM后端。您将从编译器获得更多可读的错误和警告,以及更短的编译时间。您可能还会遇到不兼容或bug;clang是一个非常年轻的项目。
  • LLVM-GCC: GCC's front-end with LLVM's back-end. LLVM's back-end is faster than GCC's.
  • LLVM-GCC: GCC前端与LLVM的后端。LLVM的后端速度比GCC快。

clang's (Objective-)C++ support is far from being complete so it calls llvm-gcc when it encounters a C++ source file. It also contains the static analyzer that is now integrated into Xcode. Some people say LLVM's back-end generates better code than GCC's but your mileage may vary. LLVM also supports link-time optimizations (which you can enable in Xcode's project settings). They may produce faster code.

clang (Objective-) c++支持还远没有完成,所以当遇到c++源文件时,它会调用llvm-gcc。它还包含现在集成到Xcode中的静态分析器。有些人说LLVM的后端生成的代码比GCC的要好,但是您的里数可能不同。LLVM还支持链接时间优化(可以在Xcode的项目设置中启用)。它们可以生成更快的代码。

Apple wants to replace GCC with clang in the future because they have a policy against GPLv3 licensed code (GCC 4.2 is the last version that's licensed under GPLv2).

苹果公司希望在未来用clang取代GCC,因为他们有针对GPLv3授权代码的策略(GCC 4.2是在GPLv2下获得许可的最后一个版本)。