Question

I have two projects based on LLVM Objective-C/C with 1M lines of code and 1.5M lines of code.

The 1.5M LoC project compiles faster for some unclear reason. It doesn't use precompiled headers and there is no explanation I could find.

I've added precompiled headers and included the biggest offenders, I've disabled dSYM generation, made the code compile ARM 7 only (not 7s) reduced the amount of optimizations to O3. Still the builds are much slower, the projects are pretty similar in structure but I can't see any major difference that would justify the slower build.

The faster building project was constructed with an older version of xcode but both are compiled with xcode 5.

Was it helpful?

Solution 2

I've noticed that changing the c language dialect to C99 from GNU99 roughly doubles the compilation speed.

We also noticed that using macros extensively (define statements) especially nested macros are REALLY slow on xcode. Removing as much of those as possible also helped tremendously and our compilation is now 2-3 times faster.

Update: Since that we also discovered that includes within headers and in general over-use of include statements was also a contributor to performance issues. By reducing the number of includes we were able to further increase the compilation speed significantly well beyond the original project. I had incorrectly assumed that due to the usage of an SSD and caching having the typical C #ifdef guards against double include would be enough to make compilation fast but it seems LLVM is really slow with such includes for some reason.

OTHER TIPS

You should look into Objective-C Modules: a compiler optimization since xcode 5. This could really speed up your compile time, by using the @import in your code instead of #import. By using this statement, the compiler only imports the used classes of the imported framework, instead of all the header files included in that framework.

More info:

http://stoneofarc.wordpress.com/2013/06/25/introduction-to-objective-c-modules/

Here's the WWDC 2013 session were it was introduced: Session 404: Advances in Objective-C

https://developer.apple.com/videos/wwdc/2013/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top