Pre-Compiled headers and GCC
#1
After madmaxoft enabled precompiled headers in the Windows builds, compile time was reduced a lot. I'm trying to do the same for *nix users by enabling precompiled headers.

However, it seems using precompiled headers actually slows down compile time O.o

How I understood the precompiled headers with GCC is that you compile a .h file the same way you compile a .cpp file and it will create a .h.gch file, place that file in the same folder as the .h file and GCC will use the .h.gch file instead of the .h file.

I checked it if works with the -H GCC parameter, and it works, but it seems to take longer to compile the project even if it's slightly slower. There's definitely no improvement though.

Am I doing something wrong?
Reply
Thanks given by:
#2
Are you precompiling the right header? VS works by precompiling one specific header and then including that header as the first one in every cpp file (that's why I added the Globals.h header). I think with gcc you want to do the same thing - precompile the Globals.h header and then proceed with normal compilation.

I'm having a friend help me with makefiles now, so you might want to postpone this a bit until we have a better makefile (that is, if he can help us Wink Right now a worse problem with *nix is that a change in the header doesn't force "make" to recompile all cpps that are affected; also i'd like to have three builds - debug, release and profiling. He said he might manage all this, but it'll take some time.
Reply
Thanks given by:
#3
Ahh great, that would be superbBig Grin

And I was compiling Globals.h yup Smile I could see it was including less header files by using -H. -H prints all headers that are included, and it was (a lot) less when I used the precompiled header, but slower nonetheless.
Reply
Thanks given by:
#4
Well you can always use at least the parallel make (make -j <number of processes>)
Reply
Thanks given by:
#5
I know and I do Smile
Reply
Thanks given by:
#6
Ever consider Cmake implementation? You can set the optimization for each platform and have it generate the build files for each users situation. I know it looks intimidating at first but it's not that hard to implement. When I get some extra time I will make a patch to share then you can see it's many advantages.
Reply
Thanks given by:
#7
I've seen CMake used in MineServer and it didn't work that well there.
And it doesn't support customizations to the project files - for example I group the source files by category (os support, packets, world generating, mobs etc.). That doesn't seem possible with cmake.
I think the status quo is sufficient - there are two active developers, each maintains their VS's project files, and the *nix makefile is generic enough to pick up anything in the right paths Smile

BUT if CMake can show us how to make gcc use precompiled headers for the project, that might be a piece of information worth extracting. Not the entire management, just the parameters / exclusions to use.
Reply
Thanks given by: AlterEgo
#8
Fair enough. But MineServer just didn't work well for anything Wink Far as the custom scripts. Cmake can me made to recognize custom scripts being added without modifying any cmake file long as they use a designated directory for there scripts. Wink

It works well in my project but I not here to discuss my project. But if you need an example just PM me and I will give you the link.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)