Ninja: cmake 3.21.3 breaks ninja dependency tracking?
TL;DR
We use cmake v3.21.3 with ninja 1.10.2 on Ubuntu 20.04. Since about cmake v3.21, we have strange problems that executables appear to be incompletely rebuild (strange jumps in the debugger, and strange crashes that are gone after a full rebuild). After some investigation, I fail to understand how ninja's dependency tracking should work. We see no references to the sources from the build tree. Is cmake not generating the DEP_FILES
, or how can I validate that ninja's dependency tracking information is there?
Longer explanation of the problem with cmake v3.21.3
I'm not sure if this can really be true, because my problem should affect too many users for this to go unnoticed! But in any case, our build system is broken, so here is what I observe:
Since roughly cmake 3.21, we have strange exceptions that indicate a broken build. These problems come randomly during development, and are always resolved with a full rebuild. We assume a broken dependency tracking such that not all object files are always rebuilt, eventually leading to very strange behavior of the program. This is what we observe in the debugger, and in the failing tests.
We use ninja, so I tried to check up on the dependency tracking in ninja. Sadly I could not find much documentation on this, but looking at build.ninja
, I assume that the DEP_FILE
setting be relevant. But no such file exists for us, for none of the sources! For example we have
DEP_FILE = CMakeFiles/ShadingCorrectionTest.dir/test/src/ShadingCorrectionTest.cc.o.d
but then after the build, there is only CMakeFiles/ShadingCorrectionTest.dir/test/src/ShadingCorrectionTest.cc.o
, no other files.
In fact, when I search in the build tree for a relevant header ShadingCorrection.hh
, I can only find it in a number of files with extension *.s
and *.ii
. I'm not sure if these are used by ninja's dependency tracking? At least these files are not referenced in build.ninja
.
Any help would be greatly appreciated!