Latest Posts

Topic: Speedup rebuilds

borim

Topic Opener
Joined: 2009-09-04, 11:13
Posts: 52
Ranking
Likes to be here
Location: germany
Posted at: 2013-03-12, 19:46

Hallo,

I would like to know if there is a possibility to use ccache for widelands to speedup rebuilds? A quick benchmark on my laptop showed that a rebuild takes normally ~35 min, with ccache only ~6 min are needed.

The blueprint on launchpad (https://blueprints.launchpad.net/widelands/+spec/add-ccache) contain some more information.

A branch with all required changes is linked, too.


Top Quote
Kiscsirke
Avatar
Joined: 2009-12-16, 12:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2013-03-12, 20:11

But why do you want to do a complete rebuild? I haven't found any problems with CMake not finding changes, so normal builds work, and they take a couple of mins at most.


Top Quote
doublep

Joined: 2013-03-07, 20:50
Posts: 5
Ranking
Just found this site
Posted at: 2013-03-13, 11:15

ccache is still useful if you make a change and then decide it wasn't good and revert. With ccache previously compiled objects just come from cache. Without it, you have to build them again.


Top Quote
QCS

Joined: 2009-12-29, 21:47
Posts: 256
Ranking
Tribe Member
Posted at: 2013-03-13, 15:48

I am not too fond of ccache. I used it a while (for Gentoo portage system wide), and it did what it should do, basically.

But there are some major drawbacks.

1.) A user may not want to have to use ccache for widelands, even if available systemwide (for example on Gentoo, to avoid cluttering the ccache with system-wide irrelevant data, or others, to avoid unnecessary writes on system SSD). So at least, make using ccache an option, not an automatic decision.

2.) Using ccache for Release builds is generally a bad idea. Release builds are always and forever clean checkouts, clean builds. So, for Release builds, ccache should always be disabled. Additionally to that, it should be possible to disable it for Debug builds (see 1.) because daily builds on build farms should contain debug information.

3.) As far as I can think, you could simply do something on the cmake call like cmake -DCMAKE_CXX_COMPILER='ccache g++' (and possibly, but not necessarily a few other -D parameters) and should be good to go, if you really want to use ccache. This doesn't add any build complexity, allows for the same requirements (see 1. and 2.), and to me it feels the same if I say "cmake -DWL_USE_CCACHE=yes" or "cmake -DCMAKE_CXX_COMPILER='ccache g++'". So, less complexity by same functionality and flexibility wins. At least for me.

So from me, a clear -1.

Edited: 2013-03-13, 16:10

CMake is evil.

Top Quote
borim

Topic Opener
Joined: 2009-09-04, 11:13
Posts: 52
Ranking
Likes to be here
Location: germany
Posted at: 2013-03-13, 19:20

@Kiscsirke: I used the complete rebuild as test case, because it is simple to reproduce. When you create a new branch ccache will already reduce the compile time for the first build, as the code does not differ from its origin face-wink.png Also after a merge ccache can help and in other situations probably, too.

@QCS: 1) For sure there should be an option to disable ccache. The attached branch contain just the minimal changes so CMake use ccache instead the normal compiler. It is no final version which can be merged to trunk. But before I invest more work, I want to know which way to go and if ccache is wanted for widelands or not.

2) I think the same about releases, they have to be clean. But you have to difference between a release build and the release itself. I did release builds multiple times, but I never release widelands face-wink.png

Just for curiosity are build farms used for widelands? As far as I know the daily builds are done by volunteers like Tino. Back to the build farms. They are a good example where ccache should be used. Building a bigger project takes some time and if the compile time is reduced that is excellent. As the next project or revision can be build.

I do not understand what your concerns for debug builds are. ccache can handle normal and debug builds.

3) To set ccache as compiler by parameter is the alternative, if ccache should not be integrated into CMake. But I think a lot of people can benefit from ccache, as we want coding widelands and not waiting for the build to finish.

Also I am for enabling ccache on default (if installed) and give an option to disable it, because I think that a shorter compile time is preferred in most cases. The release is done only from time to time. Currently once a year.


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2013-03-14, 23:01

FWIW, I use ccache for all my compiles and it is simple enough to drop a wrapper script someplace and use this as the CC compiler. I do not think Widelands build system should default to using ccache - it is very specific to make files. Some users might use Visual Studio, Eclipse, Kdevelop or something else and they would never need ccache.


Top Quote
ixprefect

Joined: 2009-02-27, 13:28
Posts: 367
Ranking
Tribe Member
Posted at: 2013-03-15, 21:28

Here's another vote against enabling ccache by default. It is too specific for individual developer's setups to be worth including in the default build system, and easy enough to add by just changing a single config value.


Top Quote
borim

Topic Opener
Joined: 2009-09-04, 11:13
Posts: 52
Ranking
Likes to be here
Location: germany
Posted at: 2013-03-16, 04:35

ok, I am over voted.


Top Quote
ixprefect

Joined: 2009-02-27, 13:28
Posts: 367
Ranking
Tribe Member
Posted at: 2013-03-16, 10:37

By the way, a follow-up that I just successfully tried out on my system: CMake selects 'c++' as the compiler executable for me, which is managed (under Debian/Ubuntu) via the /etc/alternatives/ mechanism of symbolic links. I now created the executable file /usr/lib/ccache/indirect/g++ with the following contents:

#!/bin/sh
exec /usr/lib/ccache/g++ $*

I then registered it as the preferred alternative for c++ by running (in sudo):

update-alternatives --install /usr/bin/c++ c++ /usr/lib/ccache/indirect/g++ 30

This will ensure that ccache is used automatically in all CMake projects.


Top Quote
borim

Topic Opener
Joined: 2009-09-04, 11:13
Posts: 52
Ranking
Likes to be here
Location: germany
Posted at: 2013-03-17, 11:07

You can also use the symbolic links provided by ccache /usr/lib/ccache face-wink.png


Top Quote