The benefits / disadvantages of unity builds? [duplicate]

核能气质少年 提交于 2019-11-26 04:26:25

问题


This question already has an answer here:

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

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.


回答1:


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.




回答2:


Lee Winder posted his experiences with the Unity Builds - The Evils of Unity Builds

His conclusion is:

Unity builds. I don’t like them.




回答3:


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.



来源:https://stackoverflow.com/questions/847974/the-benefits-disadvantages-of-unity-builds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!