Compile time tips


Questions, Explanations, Howtos

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Friday, 4th October 2013, 19:42

Compile time tips

Any tips or suggestions for improving compile times? I guess any other related tips would be helpful, too.
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Friday, 4th October 2013, 21:01

Re: Compile time tips

If you use Linux, install ccache. If you use Windows, use Linux instead. If you need or want windows, install virtualbox then use Linux.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...
User avatar

Dungeon Master

Posts: 502

Joined: Wednesday, 7th March 2012, 13:25

Location: Lexington, KY, US

Post Saturday, 5th October 2013, 16:32

Re: Compile time tips

ccache, as suggested by galehar, is very useful if you switch branches often. It caches the compiler output so that, even if you have switched to another branch and back and therefore made all the source files dirty, or if you made a change and then reverted it, ccache will see that you've done exactly the same compile before and use the saved output instead of running the compiler again. It is smart enough to recompile if compiler flags or headers are different.

If you do use Windows, there's supposedly a version of ccache for mingw, but I haven't tried it:
http://code.google.com/p/ccache-win32/

Also useful:

make -jN (where N is the number of cores in your machine)
runs up to -jN processes in parallel. Each call to gcc uses only one core, so this option lets you take advantage of the fact that your computer is newer than 10 years old.

make NO_OPTIMIZE=y
causes the game to run quite a bit slower, but makes compilation much faster. I wouldn't do this for my main build, but for testing it's very useful (and easier to debug).

This all applies to Unix or msysgit/mingw builds; if you're building with Visual Studio, then I have no clue.

For this message the author neil has received thanks:
Sandman25

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Saturday, 5th October 2013, 16:47

Re: Compile time tips

I apparently already had ccache installed. I set up symlinks to the compiler commands, but I don't think they're being used when I build crawl. (I don't notice any difference, and the ccache statistics don't change.) Is there a way to verify/force the particular compiler commands?

Ziggurat Zagger

Posts: 6454

Joined: Tuesday, 30th October 2012, 19:06

Post Saturday, 5th October 2013, 16:52

Re: Compile time tips

Visual studio has it's own caching system for rebuilding from non-dirty sources called 'enable minimal rebuild' the crawl visual studio project has this disabled, which means it will rebuild all files even when the sources hasn't changed, but switching it to enabled would speed that up.
Spoiler: show
This high quality signature has been hidden for your protection. To unlock it's secret, send 3 easy payments of $9.99 to me, by way of your nearest theta band or ley line. Complete your transmission by midnight tonight for a special free gift!
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Saturday, 5th October 2013, 19:58

Re: Compile time tips

BlackSheep wrote:I apparently already had ccache installed. I set up symlinks to the compiler commands, but I don't think they're being used when I build crawl. (I don't notice any difference, and the ccache statistics don't change.) Is there a way to verify/force the particular compiler commands?

which g++ should tell you which binary is being called. Personally, I put /usr/lib/ccache in my PATH instead of messing with symlinks. I think you used to have to set the cache size, but since I can't find it anymore in the doc I guess it was obsoleted instructions. But hey, INSTALL.txt now also recommends installing binutils-gold for a faster linker. Haven't tested that yet.
Also, about hardware, make sure you have enough RAM. Compiling C++ uses a lot of memory.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Saturday, 5th October 2013, 22:40

Re: Compile time tips

I tried just changing my PATH after posting, but it turned out that the line in my profile wasn't executing. Once I got that straightened out, which g++ started returning ccache. I also installed binutils-gold just now. Now I see the cache statistics updating. Let's see how this goes.

Edit: Yup, first recompile took a while but afterward make clean;make TILES=y took about 5 seconds.
User avatar

Dungeon Master

Posts: 431

Joined: Tuesday, 13th September 2011, 17:34

Post Sunday, 6th October 2013, 04:12

Re: Compile time tips

PCH=y helped a bit for me. I guess it sort of halfway compiles the headers beforehand or something -- beyond me, but it compiles a bit faster, so who cares.

Return to Coding

Who is online

Users browsing this forum: No registered users and 8 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.