The Benefits/Disadvantages of Unity Builds

The benefits / disadvantages of unity builds?

Very similar question and good answers here: #include all .cpp files into a single compilation unit?

The summary seems to be that less I/O overhead is the major benefit.

See also The Magic Of Unity Builds as linked in the above question as well.

What's the use of including implementation files in other implementation files?

This is called a unity build.

It's supposed to speed up compilation of the source code.

See a related question here that provides more details: The benefits / disadvantages of unity builds?

link-time optimization versus. project inlining; limitations on each approach

The technical name, approaching minor buzzword status, for that approach is unity build.

See for example:

The benefits / disadvantages of unity builds?

The downside is best described here:

http://leewinder.co.uk/blog/?p=394

The short version is it is more or less a choice of languages: you either write in regular-C++ or Unified-build-C++. The 'correct' way of writing virtually any code will differ between the two.

#include all .cpp files into a single compilation unit?

It's referred to by some (and google-able) as a "Unity Build". It links insanely fast and compiles reasonably quickly as well. It's great for builds you don't need to iterate on, like a release build from a central server, but it isn't necessarily for incremental building.

And it's a PITA to maintain.

EDIT: here's the first google link for more info: http://buffered.io/posts/the-magic-of-unity-builds/

The thing that makes it fast is that the compiler only needs to read in everything once, compile out, then link, rather than doing that for every .cpp file.

Bruce Dawson has a much better write up about this on his blog: http://randomascii.wordpress.com/2014/03/22/make-vc-compiles-fast-through-parallel-compilation/

What are ways of improving build/compile time?

The biggest improvement we made for our large C++ project was from distributing our builds. A couple of years ago, a full build would take about half an hour, while it's now about three minutes, of which one third is link time.

We're using a proprietary build system, but IncrediBuild is working fine for a lot of people (we couldn't get it to work reliably).



Related Topics



Leave a reply



Submit