Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone GCC / LLVM GCC or LLVM?

Tags:

Im asking the experts here...

Does anybody have made some performance test about which compiler is the best for iPhone apps?

Since we have the choice between:

  • GCC 4.2
  • LLVM GCC 4.2
  • LLVM compiler 1.5

Im wondering which of the 3 offers the best performance...

I've done some quick test myself but haven't found much difference?

Which compiler are you using?

like image 637
bob Avatar asked Sep 17 '10 23:09

bob


People also ask

Does Apple use LLVM?

Multiple technology groups within Apple are active contributors within the LLVM.org community, and they use LLVM technology to make Apple platforms faster and more secure.

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

What is LLVM in iOS?

What is the LLVM. LLVM is an umbrella project for many subprojects. All of which result in a compiler infrastructure and tool chain used today largely by developers using C/C++ based languages and which is heavily integrated in Xcode and it's compilation process.


2 Answers

If you watch the WWDC 2010 session video 300, the Developer Tools State of the Union, you will see that Apple reports significant performance increases for applications built using the LLVM compiler over GCC (up to 60% faster in certain cases). There are additional improvements that can be made by using the Clang parser with the LLVM compiler. Watch Session 312 - "What's New in the LLVM Compiler" for more on this, as well as the sessions on LLVM from WWDC 2009, if you have them.

I saw a 20% speedup going from GCC to LLVM 1.5 in an informal benchmark within one of my applications, but it wasn't a rigorous test, so consider that only anecdotal evidence.

My recommendation is to use Clang + LLVM (LLVM Compiler 1.5) if you can for faster build times, more performant applications, and much better compiler errors. If you use C++ code or something else that the Clang parser cannot handle right now, use LLVM GCC to still get the performance benefits in your compiled application. Go to GCC only if that fails for some reason. It's a simple switch to hit in your build settings to gain even a small amount of extra performance for free in your end application.

LLVM Compiler 2.0, coming with Xcode 4, has full support for C++ and promises additional optimizations for compiled applications, along with more compile-time speedups. Xcode 4 even uses Clang as the syntax highlighting / code correction engine in the IDE. It's clear the direction that Apple is heading with their compilers.

like image 182
Brad Larson Avatar answered Oct 02 '22 13:10

Brad Larson


I do not know about performance for the iPhone, but in other benchmarks, Clang generally compiles faster but produces slower code than GCC. Clang also has better error messages than GCC. Thus, it might be best to use Clang in development, and switch to GCC for final production builds. If you choose such an approach, make sure you have a good QA cycle, or a build system that will also build and test the GCC build, so you don't get any nasty compiler related surprises at the end.

C++ support in Clang is a bit behind that of GCC (and more C++ code has been tested and tweaked for GCC's quirks than Clang's), so if you need to use a lot of C++, GCC might be a better option.

Really, you will need to choose the best compiler for your needs. Benchmarks, and other people's results, can give you an indication of what to consider, but every program is different, so the best approach would be to benchmark your own program on the different compilers, and see which works best for you.

like image 33
Brian Campbell Avatar answered Oct 02 '22 13:10

Brian Campbell