CMake’s collator generates a ninja dyndep file that adds restat = 1
to the compilation rule for the module interface unit’s object file. That tells ninja to stat()
the outputs again after the compiler runs in order to check which outputs really changed. Ninja should recognize that consumers of unchanged outputs do not need to rebuild.
I tested this locally. When the module interface doesn’t change, clang writes an identical .pcm
file, but it still updates the timestamp of the .pcm
file. That prevents Ninja from recognizing that the module interface hasn’t changed, so it still recompiles dependents. This is a problem in Clang.