LLVM vs. GCC for iOS development [closed]

Solution 1:

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).


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.

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

Solution 2:

Ok, I think none of the answers below tell the whole story, so here's my take on a response to my question:

  • LLVM compiles code faster than GCC, may create code that runs faster, and the Clang frontend provides more accurate error messages than GCC – so there are definitely reasons for switching;

  • that said, the version provided with latest stable Xcode (LLVM 1.6) is not 100% stable yet, you can run into some minor bugs if you're unlucky. So if you want to be safe, you should either compile the latest LLVM (2.0) from source, or stick to GCC for the next few months;

  • in a few months, probably when Apple releases Xcode 4, LLVM 2.0 will be the version that ships with Xcode by default, and then we should all be able to switch to it safely.

Thanks to everyone who responded, feel free to correct me if I got something wrong.

Solution 3:

I have an app that seems to crash on launch on the original iPhone running iOS 3.1.3 when compiled with LLVM 2.0, but runs just fine with LLVM-GCC. I support back to iOS 3.1 so this is fatal. Not sure if there's an interaction between LLVM 2.0 and some specific code I have, but it seems best to avoid LLVM if you need to support iOS 3.x unless you can test thoroughly on legacy devices.


Update: It seems that the issue is with the device hardware rather than iOS version. 1st and 2nd generation iOS devices seems to be affected: Original iPhone, iPhone 3G, and 1st and 2nd gen iPod Touch. I believe this means it's limited to ARMv6 architectures.

Also, running a debug build via Xcode's debugger works fine, while release builds installed via iTunes do not. So it might be an interaction between CPU architecture and optimization level with LLVM 2.0.

But in any case, avoid for now ;)

Solution 4:

Another major reason to switch to Clang is more accurate (column & line number ranges) and readable error messages.

Solution 5:

During the latest WWDC10 they made a point of encouraging developers to use the more current LLVM compiler. I forget the exact tract that they covered it in detail - one of the "new in Xcode". Basically they suggest using LLVM-2.0 when possible, otherwise LLVM-GCC and to avoid GCC alone completely.

If you're a registered iOS developer, you can view most of the sessions free at http://developer.apple.com/videos/wwdc/2010/