Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I start targeting Clang / LLVM with my C++ iPhone project?

Apple is pushing LLVM and Clang a lot. Rumors say it's because Apple wants to drop GCC (due to problems with GPLv3 license), and switch to Clang.

Anybody has any idea about when it is going to happen?

I'm starting a C++ project which I'm planning to port on iPhone, and don't know whether I should use C++0x features (at least the ones supported by Clang), or if I should write code compatible with GCC 4.1...

like image 955
peoro Avatar asked Dec 12 '10 14:12

peoro


Video Answer


1 Answers

Rumors say it's because Apple wants to drop GCC (due to problems with GPLv3 license), and switch to Clang.

This isn't a rumor, this is Apple's stated position. The GPL license on GCC prevents Apple from thoroughly integrating the compiler / parser within their development tools. With Clang / LLVM, they have no such restriction and thus are able to do far more with their tools (starting with the integrated Clang Static Analyzer in Xcode 3.2 and going much further with Xcode 4).

Beyond the license issues, Clang / LLVM builds much faster than GCC and in Apple's benchmarks (and my own experience) creates better-performing executables than GCC. It generates far more helpful error messages as well. It's been architected in a modular fashion, which should also make it easier to maintain and extend than GCC going forward.

Apple has stated that all C++ features except exported templates are supported in the upcoming LLVM Compiler 2.0 in Xcode 4, and the compiler has been self-hosting for a little while now. If you can't wait, or don't want to try the Xcode 4 developer previews, you can check out the compiler now by grabbing the source code from the main LLVM site.

I highly recommend watching the freely available WWDC 2010 videos for session 300 - "Developer Tools State of the Union" and session 312 - "What's New in the LLVM Compiler" where they lay out what they are currently working towards with the LLVM compiler.

Timing-wise, only Apple can tell you when they will do something, and even they can't know exactly when something will be ready for primetime. You can make educated guesses based on the improvement trajectory of the Xcode developer previews, but that's all. However, Clang / LLVM is the way that Apple's going, so why not plan for that?

like image 111
Brad Larson Avatar answered Sep 27 '22 19:09

Brad Larson