|Subject:||Build Rule Race Condition|
|Date:||Tue, 18 Aug 2009 16:45:41 -0700|
I recently inherited a large make-based build system that defines a large amount of nested and complex build rules. In it, I have discovered a build race condition problem that the original owner never looked into and just accepted:
There is a build rule that is causing a problem because it says that if any of 3 output files are out-of-date compared to a common source file, run a program to process the source file and produce the 3 output files. The simplified rule is as follows:
myfile.a myfile.b myfile.c: myfile.source
process then opens all 3 output files for writing.
This works fine with a sequential non-parallel make run, but because the system is so big, we need to run make with multiple jobs. The problem with multiple jobs is that when make detects that 2 or more of myfile.a, myfile.b, and myfile.c are out of date, it runs “process” separately for each output file (start_job_command fires once for each). Every once in awhile each instance of “process” attempts to open the output files at the same time, and all except the first instance fail to open the file for writing. The write failures propagate to make, which proceeds to bail and log the entire build as a failure. Great sadness ensues.
The ideal solution is for make to link all 3 output files together, so that as soon as it fires the job to process any of the 3, all 3 are marked as “running” and no further jobs are started. Is this possible with make?
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
|[Prev in Thread]||Current Thread||[Next in Thread]|