LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   ccache, precompiled headers & C++ - Doesn't work as well as imagined (http://www.linuxquestions.org/questions/programming-9/ccache-precompiled-headers-and-c-doesnt-work-as-well-as-imagined-292688/)

ripat 02-20-2005 02:24 PM

ccache, precompiled headers & C++ - Doesn't work as well as imagined
 
Hi, I recently tried to decrease the compile times for a C++ project of mine. I have tried ccache and using precompiled headers, both work well alone but ccache doesn't seem to work together with precompiled headers. The compile times actually increase if they are used togeteher!

I wonder if anyone else have noticed this behavior?



Some more info follows:


This is my timed compile times:

(System: PII-450MHz, 320MB RAM, Mandrake-Linux 10.1, g++ 3.4.1-4mdk, ccache v2.4)

No ccache, no precompiled commonheaders
---------------------------------------
Rebuild all: 4:04
Incremental build (changes in two files): 1:47

only ccache
-----------
Rebuild all (clean cache): 4:21
Incremental build (changes in two files): 0:44
Rebuild all (no changes): 0:30
Incremental build (changes in two files): 0:28

only precompiled commonheaders
------------------------------
Rebuild all: 2:37, 1:36, 1:50, 1:36
Incremental build (changes in two files): 0:10, 0:10

ccache (empty cache) + precompiled commonheaders
------------------------------------------------
Rebuild all: 6:24, 5:30, 7:08, 7:34 (!?)
Incremental build (changes in two files): 0:44, 0:45
Rebuild all (no changes): 9:06, 5:28
Incremental build (changes in two files): 0:45, 0:44






It seems like ccache can't handle this situation because this is what I get if I run ccache -s after a compile with precompiled headers:

-----
cache directory /home/xxx/.ccache
cache hit 0
cache miss 0
called for link 4
preprocessor error 32
unsupported compiler option 2
files in cache 0
cache size 0 Kbytes
max cache size 976.6 Mbytes
-----





My "commonheader.h" file


#ifndef COMMONHEADERS_H
#define COMMONHEADERS_H

//#include "commonheaders.h"
//------------------------


// This headerfile includes all common include files that
// are needed for the project and doesn't change often.

// The idea is to speed up compile times using precompiled headers. See
// http://www.bcbdev.com/articles/pch.htm

// You have to tell the qmake project file that this file should be
// precompiled, otherwise it will actually seem to be slower:
//
// CONFIG += precompile_header
// PRECOMPILED_HEADER += commonheaders.h

using namespace std;

/* Add C includes here */

#if defined __cplusplus
/* Add C++ includes here */

// QT Classes
#include <qapplication.h>
#include <qstring.h>
#include <qsettings.h>
#include <qtable.h>
#include <qfiledialog.h>
#include <qstringlist.h>
#include <qwidget.h>
#include <qprocess.h>
#include <qtextstream.h>
#include <qmessagebox.h>

// Standard c++ classes
#include <iostream>
#include <map>
#include <fstream>
#include <sstream>
#include <utility>

// Project classes
#include "constants.h"
#include "profiletableitem.h"

#endif

#endif


All times are GMT -5. The time now is 05:23 AM.