部分構建與Visual C ++中的完整構建

[英]Partial builds versus full builds in Visual C++


For most of my development work with Visual C++, I am using partial builds, e.g. press F7 and only changed C++ files and their dependencies get rebuilt, followed by an incremental link. Before passing a version onto testing, I take the precaution of doing a full rebuild, which takes about 45 minutes on my current project. I have seen many posts and articles advocating this action, but wonder is this necessary, and if so, why? Does it affect the delivered EXE or the associated PDB (which we also use in testing)? Would the software function any different from a testing perspective?

對於我使用Visual C ++的大多數開發工作,我使用的是部分構建,例如按F7並僅更改C ++文件並重建其依賴項,然后是增量鏈接。在將版本傳遞給測試之前,我采取了完全重建的預防措施,這在我當前的項目上大約需要45分鍾。我看過很多帖子和文章都主張這個動作,但是這是必要的,如果有的話,為什么呢?它是否影響交付的EXE或相關的PDB(我們也在測試中使用)?軟件功能與測試角度有何不同?

For release builds, I'm using VS2005, incremental compilation and linking, precompiled headers.

對於發布版本,我使用的是VS2005,增量編譯和鏈接,預編譯頭文件。

6 个解决方案

#1


2  

Hasn't everyone come across this usage pattern? I get weird build errors, and before even investigating I do a full rebuild, and the problem goes away.

不是每個人都遇到過這種使用模式嗎?我得到了奇怪的構建錯誤,甚至在調查之前我進行了完全重建,問題就消失了。

This by itself seems to me to be good enough reason to do a full rebuild before a release.

在我看來,這本身就足以讓你在發布之前進行完全重建。

Whether you would be willing to turn an incremental build that completes without problems over to testing, is a matter of taste, I think.

我認為,無論你是否願意將沒有問題的增量構建轉換為測試,都是一個品味問題。

#2


6  

The partial build system works by checking file dates of source files against the build results. So it can break if you e.g. restore an earlier file from source control. The earlier file would have a modified date earlier than the build product, so the product wouldn't be rebuilt. To protect against these errors, you should do a complete build if it is a final build. While you are developing though, incremental builds are of course much more efficient.

部分構建系統通過根據構建結果檢查源文件的文件日期來工作。所以它可能會破壞你,例如從源代碼管理中恢復早期文件。早期文件的修改日期早於構建產品,因此不會重建產品。為了防止出現這些錯誤,如果是最終版本,則應該進行完整構建。在開發過程中,增量構建當然要高效得多。

Edit: And of course, doing a full rebuild also shields you from possible bugs in the incremental build system.

編輯:當然,進行完全重建也可以保護您免受增量構建系統中可能存在的錯誤的影響。

#3


3  

The basic problem is that compilation is dependent on the environment (command-line flags, libraries available, and probably some Black Magic), and so two compilations will only have the same result if they are performed in the same conditions. For testing and deployment, you want to make sure that the environments are as controlled as possible and you aren't getting wacky behaviours due to odd code. A good example is if you update a system library, then recompile half the files - half are still trying to use the old code, half are not. In a perfect world, this would either error out right away or not cause any problems, but sadly, sometimes neither of those happen. As a result, doing a complete recompilation avoids a lot of problems associated with a staggered build process.

基本問題是編譯依賴於環境(命令行標志,可用庫,可能還有一些Black Magic),因此如果在相同條件下執行,則兩個編譯只會產生相同的結果。對於測試和部署,您希望確保環境盡可能受控制,並且由於奇怪的代碼而您沒有獲得古怪的行為。一個很好的例子是如果你更新一個系統庫,然后重新編譯一半的文件 - 一半仍在嘗試使用舊代碼,一半不是。在一個完美的世界中,這可能會立即出錯或者不會引起任何問題,但遺憾的是,有時這些都不會發生。因此,執行完整的重新編譯可避免與交錯構建過程相關的許多問題。

#4


2  

I would definitely recommend it. I have seen on a number of occasions with a large Visual C++ solution the dependency checker fail to pick up some dependency on changed code. When this change is to a header file that effects the size of an object very strange things can start to happen. I am sure the dependency checker has got better in VS 2008, but I still wouldn't trust it for a release build.

我肯定會推薦它。我已經在很多場合看到過使用大型Visual C ++解決方案,依賴檢查器無法獲得對已更改代碼的某些依賴。當這個改變是一個影響對象大小的頭文件時,很奇怪的事情就會開始發生。我確信依賴檢查器在VS 2008中有所改進,但我仍然不相信它的發布版本。

#5


2  

The biggest reason not to ship an incrementally linked binary is that some optimizations are disabled. The linker will leave padding between functions (to make it easier to replace them on the next incremental link). This adds some bloat to the binary. There may be extra jumps as well, which changes the memory access pattern and can cause extra paging and/or cache misses. Older versions of functions may continue to reside in the executable even though they are never called. This also leads to binary bloat and slower performance. And you certainly can't use link-time code generation with incremental linking, so you miss out on more optimizations.

不發布增量鏈接二進制文件的最大原因是某些優化被禁用。鏈接器將在函數之間留下填充(以便在下一個增量鏈接上更容易替換它們)。這給二進制文件增加了一些膨脹。可能還有額外的跳轉,這會改變內存訪問模式,並可能導致額外的分頁和/或緩存未命中。舊版本的函數可能會繼續駐留在可執行文件中,即使它們從未被調用過。這也會導致二進制膨脹和性能下降。而且你當然不能使用增量鏈接生成鏈接時代碼,所以你錯過了更多的優化。

If you're giving a debug build to a tester, then it probably isn't a big deal. But your release candidates should be built from scratch in release mode, preferably on a dedicated build machine with a controlled environment.

如果你給測試人員一個調試版本,那么它可能不是什么大問題。但是您的發布候選版本應該在發布模式下從頭開始構建,最好是在具有受控環境的專用構建機器上構建。

#6


1  

Visual Studio has some problems with partial (incremental) builds, (I mostly encountered linking errors) From time to time, it is very useful to have a full rebuild.

Visual Studio在部分(增量)構建方面存在一些問題(我經常遇到鏈接錯誤)。有時候,完全重建是非常有用的。

In case of long compilation times, there are two solutions:

如果編譯時間很長,有兩種解決方案:

  1. Use a parallel compilation tool and take advantage of your (assumed) multi core hardware.
  2. 使用並行編譯工具並利用您的(假定的)多核硬件。

  3. Use a build machine. What I use most is a separate build machine, with a CruiseControl set up, that performs full rebuilds from time to time. The "official" release that I provide to the testing team, and, eventually, to the customer, is always taken from the build machine, not from the developer's environment.
  4. 使用構建機器。我最常用的是一台單獨的構建機器,設置了CruiseControl,可以不時執行完全重建。我向測試團隊提供的“官方”版本,以及最終提供給客戶的版本,總是來自構建機器,而不是來自開發人員的環境。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/05/11/7207e6bc69d0b4db27e1a5fabb27aaf0.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com