No acceleration with precompiled headers on gcc (but great acceleration with visual studio)

I am working on a large project that should build in several environments, mainly linux / gcc and windows / msvc. To speed up the build, we use precompiled headers.

Windows implementation is very efficient: on my quad-core hyper-thread, i7 build time is reduced from 9 minutes to 1.5 minutes. However, using precompiled headers does not improve performance: in both cases, it is created in 22 minutes under a virtual box on the same computer, or about 40 minutes on a real server.

So, I think I realized that something is wrong with me, and that the precompiled header is not kicking. However, I can not find.

Our Makefiles are generated by CMake, so I can copy the paste of the code used to compile the header and files of objects that use them.

Create header:

/usr/bin/c++ -O3 -DNDEBUG --no-warnings "-I/mnt/code/server a/src/game"
"-I/mnt/code/server a/src/game/vmap" "-I/mnt/code/server a/dep/include/g3dlite"
"-I/mnt/code/server a/dep/include" "-I/mnt/code/server a/src/shared"
"-I/mnt/code/server a/src/framework" "-I/mnt/code/server a/buildlinux"
"-I/mnt/code/server a/buildlinux/src/shared" -I/usr/include/mysql
"-I/mnt/code/server a/dep/acelite" -DDO_MYSQL -DHAVE_CONFIG_H
-DVERSION=\"0.6.1\" -DSYSCONFDIR=\"../etc/\" -D_RELEASE -D_NDEBUG -x c++-header
-o "/mnt/code/server a/buildlinux/src/game/pchdef.h.gch" "/mnt/code/server
a/src/game/pchdef.h"

Compiling the object file:

/usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) "-I/mnt/code/server
a/buildlinux/src/game" -include pchdef.h -Winvalid-pch -o
CMakeFiles/game.dir/AccountMgr.cpp.o -c "/mnt/code/server
a/src/game/AccountMgr.cpp"

The views are appreciated even if they do not get directly from the fragments above.

+5
source share
1 answer

There are a few things to look for when using precompiled headers in GCC. First of all, a precompiled header must be created with the same arguments as the cpp files. Also suppose you included a precompiled header in AccountMgr.cpp?

-H, , . , pchdef , , . gcc PCH, -Winvalid-pch.

+1

All Articles