用于 iOS 开发的 LLVM 与 GCC [英] LLVM vs. GCC for iOS development

查看:24
本文介绍了用于 iOS 开发的 LLVM 与 GCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最新的 iOS SDK 中,Apple 提供了三种编译器选项:GCC、LLVM with Clang 和 LLVM-GCC.我或多或少地了解这 3 个是什么意思,LLVM 和 Clang 是什么,等等.我不知道这对 iPhone 开发人员在实践中意味着什么.截至 2011 年 1 月,此时我应该使用哪一个?LLVM 是否足够成熟,以至于我可以安全地使用它而不会经常遇到错误?切换到 LLVM 还有其他缺点吗?如果是这样,那么速度优势是否超过了它们?除了速度之外,还有什么其他原因需要切换吗?

In latest iOS SDK, Apple provides three compiler options: GCC, LLVM with Clang and LLVM-GCC. I understand more or less what these 3 mean, what LLVM and Clang are, and so on. What I don't know is what this means in practice for iPhone developers. Which of these should I use at this point, as of January 2011? Is LLVM mature enough that I can use it safely without stumbling on bugs in it too often? Does switching to LLVM have any other disadvantages? If it does, then does the speed advantage outweigh them? Are there any other reasons to switch except speed?

推荐答案

更新: 因为人们仍在寻找这个答案,我觉得我应该提供一个合适的更新.到目前为止,我希望 Clang 绝对是编程时要走的路,Clang 是新版本 Xcode 中的默认编译器,并支持 ARC 和新的和即将推出的语言结构(数组和字典下标、文字等).几乎完全没有理由再使用 GCC 进行编译了,对于使用 ARC 和新特性的代码库,使用普通 GCC 不再相关或不可能(LLVM-GCC 可能支持这些特性,但由于 Clang 完全是稳定).

Update: Because people are still finding this answer, I feel like I should provide a suitable update. By now, I hope it's clear that Clang is absolutely the way to go when programming, with Clang being the default compiler in the newer versions of Xcode and supporting ARC and new and upcoming language constructs (array and dictionary subscripting, literals, etc.). There's almost absolutely no reason to compile with GCC anymore, and for codebases using ARC and new features, using plain GCC is no longer relevant or possible (LLVM-GCC may support these features, but it provides no advantage over Clang now that Clang is completely stable).

到目前为止(LLVM-2.0 包含在 Xcode 4.0 测试版中),LLVM 已经足够成熟,可以用于生产代码.它的编译速度比 GCC 快一点,生成的代码也更快,所以尽可能使用它(几乎,如果有更好的东西,尽量避免使用 GCC).标准的 Xcode 3.2.5 安装包含 LLVM-1.6(不是最新版本),因此我建议您运行一些速度测试以查看 GCC 和 LLVM 之间是否存在明显差异,或者从源代码编译 Clang 并获取最新版本.

By now (with LLVM-2.0 included in the Xcode 4.0 beta), LLVM is mature enough for production code use. It compiles a little quicker than GCC, and produces faster code, so use it whenever you can (pretty much, try to avoid GCC if something better is available). The standard Xcode 3.2.5 install contains LLVM-1.6 (not the latest), so I'd recommend either running some speed tests to see if there's a noticeable difference between GCC and LLVM, or compiling Clang from source and getting the latest version.

本质上,GCC 已经不需要了,LLVM + Clang 绰绰有余.

Essentially, there's no need for GCC any more, LLVM + Clang is more than enough.

这篇关于用于 iOS 开发的 LLVM 与 GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆