views:

252

answers:

5

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 funtion any different from a testing perspective?

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

+3  A: 

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.

TonJ
More risk assessment than tast probably, but I agree with you. My experience is that partial rebuilds can have bugs that are cured by a full rebuild, and thus it is not reasonable to hand them over for testing. Pity, it would save me a number of hours per week.
Shane MacLaughlin
+2  A: 

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.

coppro
+5  A: 

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.

Frederik Slijkerman
It's the possible bugs in the incremental build system that concern me. Like others here, I've had a partial build fail, do a full rebuild and everything is hunky dory. Nothing in the environment has changed, this is a full rebuild immediately after a partial build without changing anything else. I guess I'll keep doing this.
Shane MacLaughlin
+2  A: 

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.

Nic Strong
+1  A: 

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.

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. 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.
Cătălin Pitiș