Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM vs. GCC for iOS development [closed]

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?

like image 830
Kuba Suder Avatar asked Jan 03 '11 23:01

Kuba Suder


People also ask

Is LLVM better than GCC?

While LLVM and GCC both support a wide variety languages and libraries, they are licensed and developed differently. LLVM libraries are licensed more liberally and GCC has more restrictions for its reuse. When it comes to performance differences, GCC has been considered superior in the past.

Does Apple use LLVM?

All of Apple's operating systems, iOS, macOS, tvOS and watchOS, are built with LLVM technologies. And Xcode, Apple's integrated development environment, supports development in Swift, C, C++, and Objective-C, all of which use and are built with LLVM technologies.

Does Apple use GCC?

Apple uses a specialized version of GCC 4.0 and 4.2 in Leopard's Xcode 3.1 that supports compiling Objective-C/C/C++ code to both PowerPC and Intel targets on the desktop and uses GCC 4.0 to target ARM development on the iPhone.

Is LLVM slower than GCC?

While LLVM's Clang C/C++ compiler was traditionally known for its faster build speeds than GCC, in recent releases of GCC the build speeds have improved and in some areas LLVM/Clang has slowed down with further optimization passes and other work added to its growing code-base.


1 Answers

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.

like image 79
Itai Ferber Avatar answered Sep 16 '22 21:09

Itai Ferber