Since starting at a new company I've noticed that they use unity cpp files for the majority of our solution, and I was wondering if anyone is able to give me a definitive reason as to why and how these speed up the build process? I would've thought that editing one cpp file in the unity files will force recompilation of all of them.
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.
Lee Winder posted his experiences with the Unity Builds - The Evils of Unity Builds
His conclusion is:
Unity builds. I don’t like them.
It's because it saves redundant work. Redundant parsing and compilation for dependencies. Linking is also much more complex -- you either have your exports all in one object (or a few), or it's separate redundant exports across most of the target's object files. Fewer objects result in less I/O and reduced link times. Depending on your setup, inclusion could be a problem -- on the "unity build" system I use, the build is ultimately CPU and/or memory bound.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With