Jump to content

Precompiled headers for *nix build


Guest freghar
 Share

Recommended Posts

Here we go, simply pull from my repo:

for master: git://github.com/freghar/mangos.git gch

for mangos-0.12: git://github.com/freghar/mangos.git gch-0.12

  • * What bug does the patch fix? What features does the patch add?
    Adds precompiled header support for Makefile/autotools based build system.
    * For which repository revision was the patch created?
    MaNGOS HEADs as of this date (1249052020), shouldn't conflict with anything made in the last few months.
    * Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.
    Nothing I know about.
    * Who has been writing this patch? Please include either forum user names or email addresses.
    Freghar

It's a basic implementation used (probably) only by gcc family. For some reason, it hasn't so cool effect seen on windows build, but it reduced compile time on my src/game/ from 24 minutes to 14 minutes.

You can measure the exact time via "time make" instead of "make". It will show statistics after it finishes.

It's also possible (for test reasons) to build only game to see more exact difference before/after.

If you're going to post any statistics, please use 46daad5f54b (or c1d5f68c1 for mangos-0.12) to measure the time WITHOUT precompiled headers, so we have something to compare the pch results with (for more git-advanced people: it's actually gch~4 / gch-0.12~4).

To compile only src/game/, do the autoreconf + configure steps and then "cd objdir/src/game/" before make.

note: gch isn't a typo for pch, it's "gnu precompiled header" - their implementation of it for the gcc family

Thanks to all the people who kept supporting me when I ran on gcc bugs.

edit: for those interested in diff/patch, see http://github.com/freghar/mangos/commits/gch -- changes are the same for both master and mangos-0.12 branches.

Link to comment
Share on other sites

just a plain statistic for master and building only game with -O0 and -j2

12:00 without this patch and 7:30 with this patch

also again: big thanks for this patch.. :)

with that i'll have everyday 4:30min*NumberOfMangosCompilation more time to do something else :)

Link to comment
Share on other sites

could someone generate a patch for the latest rev and post it here, thanks?!

Well I would have to update it everytime I fix something .. you can generate it by diff origin/master FETCH_HEAD after fetch for example .. there was IIRC some "raw diff" thing on github as well.

edit: well here it is, if it's get outdated, don't blame me;

diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index b06ebbe..9bc9767 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -19,7 +19,25 @@
## Sub-directories to parse

## CPP flags for includes, defines, etc.
-AM_CPPFLAGS = $(MANGOS_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(srcdir)/../../dep/include -I$(srcdir)/../framework -I$(srcdir)/../shared -I$(srcdir)/../shared/vmap -I$(srcdir)/../realmd -DSYSCONFDIR=\\"$(sysconfdir)/\\"
+DEF_CPPFLAGS = $(MANGOS_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(srcdir)/../../dep/include -I$(srcdir)/../framework -I$(srcdir)/../shared -I$(srcdir)/../shared/vmap -I$(srcdir)/../realmd -DSYSCONFDIR=\\"$(sysconfdir)/\\"
+AM_CPPFLAGS = $(DEF_CPPFLAGS)
+
+## Precompiled headers
+# need to be processed before *_SOURCES
+# builddir can be used, since we already -I.
+pch_src = pchdef.h
+pch_out = pchdef.h.gch
+
+BUILT_SOURCES = $(builddir)/$(pch_out)
+CLEANFILES = $(builddir)/$(pch_out)
+AM_CPPFLAGS += -Winvalid-pch -include $(pch_src)
+
+# taken from CXXCOMPILE, changed AM_CPPFLAGS to DEF_CPPFLAGS
+PCHCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \\
+       $(DEF_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+
+$(builddir)/$(pch_out): ${srcdir}/$(pch_src)
+       $(PCHCOMPILE) $(PCHFLAGS) -x c++-header -c -o [email protected] $<

## Build MaNGOS game library as convenience library.
#  All libraries will be convenience libraries. Might be changed to shared

Link to comment
Share on other sites

Pushed new version, supports --disable-pch and --enable-pch (default). Also thanks a lot to Derex for solving the pchdef dependency issue. Now should any modifications of included (and nested) headers trigger recompilation.

The speed difference isn't really big, but it helps.

--disable-pch:
user    18m31.065s
user    18m32.474s
user    18m32.270s

--enable-pch:
user    12m44.244s
user    12m44.284s
user    12m43.860s

Link to comment
Share on other sites

  • 2 years later...
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use