Two simplified makefiles
makefile1
a.txt:
echo “123144234” > a.txt
t2: a.txt
cat a.txt > b.txt
makefile2
t1:
echo “123144234” > a.txt
t2: t1
cat a.txt > b.txt
Both makefiles have the same functionality.
Both makefiles can be run in parallel because the dependency of t2 on t1.
However, there is a critical difference which might?/does? make a difference when it comes to distributed builds.
In makefile1, t2 depends directly on the artifact a.txt which is also the same as the name of the target itself a.txt. However, in makefile2, while the recipe and artifact of t1 is same as for a.txt, the name of the target is not a.txt.
This difference is key because gnu make (and I assume distcc) does NOT parse the recipe - nor analyze the filesystem at runtime - to determine all the artifacts for a given target. In makefile2, gnu make does NOT create ANY relationship between a.txt and t1.
When the build is done as make -j i.e. parallel but not distributed, this difference is irrelevant because all make targets are run on the same machine i.e. all the make instances access the same filesystem.
But let's consider what could?/does? happen during a distributed build if the two targets are built on two separate machines
In both makefiles, the recipe for t2 would be run AFTER the recipe for a.txt/t1.
However, in makefile1 the dependency of t2 on a.txt is explicit i.e. distcc knows that to make t2 on a separate machine, it must send the file a.txt to that separate machine.
QUESTION
- If makefile2 is run using
distcc, without a synchronized distributed filesystem, andt2ismaked on another machine, will there be a build error becausea.txtis not present on the other machine? - What are the options for a distributed Linux filesystem?