Search code examples
language-lawyerrebuildbuild-system

Are run-time errors that disappear on rebuild indicative of bugs in the build system?


We've all heard it - "try a clean build and see if it works". Oftentimes weird run-time errors will disappear after a rebuild. This has made me think - properly tracking dependencies is the job of a build system.

Are such runtime errors by definition bugs in a build system - whether it is make, or msbuild, or whichever. Or put another way, if a clean build and a normal build yield different results, is that by definition a bug in the build system?

Edit: I am assuming the build environment is sane - meaning that when files are updated, their "last modified" timestamp becomes newer (instead of an older timestamp or the same). In fact, all version control systems that I know of follow that rule because otherwise they would break build systems like Make that rely on the timestamps to track which files need to be updated.


Solution

  • Build systems can be optimized for performance or completeness.

    Rebuild all is a completeness build.

    The reason a partial rebuild fails is

    • incorrect knowledge. A library is built, but a fragmented build system does not understand the dependencies of the whole.
    • missing dependencies. Although the direct dependencies of header to c code are understood, indirect dependencies are missed.
    • edit and continue mis-compile. The partial build mid understands the consequences of a code change, and does not recompile enough.

    All these mistakes are offset by the advantages

    • simpler to maintain make files
    • faster compiles
    • quicker bug turn around

    You need to make your own judgement on where the value lies