4


I am using SUSE10 (64 bit)/AIX (5.1) and HP I64 (11.3) to compile my application. Just to give some background, my application has around 200KLOC (2Lacs) lines of code (without templates). It is purely C++ code. From measurements, I see that compile time ranges from 45 minutes(SUSE) to around 75 minutes(AIX).

Question 1 : Is this time normal (acceptable)?

Question 2 : I want to re-engineer the code arrangement and reduce the compile time. Is there any GNU tool which can help me to do this?

PS :
a. Most of the question in stackoverflow was related to Visual Studio, so I had to post a separate question.
b. I use gcc 4.1.2 version.
c. Another info (which might be useful) is code is spread across around 130 .cpp files but code distribution varies from 1KLOC to 8 KLOCK in a file.

Thanks in advance for you help!!!

Edit 1 (after comments)
@PaulR "Are you using makefiles for this ? Do you always do a full (clean) build or just build incrementally ?"
Yes we are using make files for project building.
Sometimes we are forced to do the full build (like over-night build/run or automated run or refresh complete code since many members have changed many files). So I have posted in general sense.

kumar_m_kiran
  • 3,982
  • 4
  • 47
  • 72
  • Are you using makefiles for this ? Do you always do a full (clean) build or just build incrementally ? – Paul R Oct 01 '10 at 06:55
  • The build times seem too big to me. I bet it's a hardware problem. You should try to use a faster processor. Additionally, you might benefit from installing more RAM, since gcc compiles C++ code with use of a lot of RAM, and swapping could be your problem. – P Shved Oct 01 '10 at 07:54

6 Answers6

4

Excessive (or seemingly excessive) compilation times are often caused by an overly complicated include file hierarchy.

While not exactly a tool for this purpose, doxygen could be quite helpful: among other charts it can display the include file hierarchy for every source file in the project. I have found many interesting and convoluted include dependencies in my projects.

albert
  • 8,285
  • 3
  • 19
  • 32
LaszloG
  • 719
  • 3
  • 5
  • +1 for doxygen as a good way of getting a handle on the size and structure of a codebase. In particular I find the Directories page incredibly useful as it shows the dependencies between headers in different directories. – the_mandrill Oct 01 '10 at 08:18
3

Read John Lakos's Large-Scale C++ Design for some very good methods of analysing and re-organising the structure of the project in order to minimise dependencies. Ultimately the time taken to build a large project increases as the amount of code increases, but also as the dependencies increase (or at least the impact of changes to header files increases as the dependencies increase). So minimising those dependencies is one thing to aim for. Lakos's concept of Levelization is very helpful in working out how to split several large monolothic inter-dependent libraries into something with a much better structure.

the_mandrill
  • 29,792
  • 6
  • 64
  • 93
2

I can't address your specific questions but I use ccache to help with compile times, which caches object files and will use the same ones if source files do not change. If you are using SuSE, it should come with your distribution.

Chance
  • 2,653
  • 2
  • 26
  • 33
2

In addition to the already mentioned ccache, have a look at distcc. Throwing more hardware at such a scalable problem is cheap and simple.

MSalters
  • 173,980
  • 10
  • 155
  • 350
1

Long compile times in large C++ projects are almost always caused by inappropriate use of header files. Section 9.3.2 of The C++ Programming Language provide some useful points this. Precompiling header files can considerably reduce compile time of large projects. See the GNU documentation on Precompiled Headers for more information.

Vijay Mathew
  • 26,737
  • 4
  • 62
  • 93
1

Make sure that your main make targets can be executed in parallel (make -j <CPU_COUNT+1>) and of course try to use ccache. In addition we experimented with ccache and RAM disks, if you export CCACHE_DIR and point it to a RAM disk this will speed up your compilation process as well.

grundprinzip
  • 2,471
  • 1
  • 20
  • 34