-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve incremental build: Make outputs modified outside of the build system considered dirty #1951
base: master
Are you sure you want to change the base?
Improve incremental build: Make outputs modified outside of the build system considered dirty #1951
Conversation
In the case an output mtime is more recent than its log entry, the output should be considered dirty since its state is not equal to the state it would have if the rule command was executed again.
f52e08b
to
f3c6ed7
Compare
Cc: @jdrouhard |
Few thoughts:
|
I have looked at #1943 and I understand what it solves and how it is incompatible with my PR. Actually it is not an implementation incompatibility, it is a ninja specification incompatibility: is the purpose of a ninja build to give the same result as a full rebuild? If the answer is yes, the problem addressed by #1943 (i.e what happen if inputs change after starting executing a rule command but before the output has been written) should lead to a ninja build failure. The current solution of #1943 is to succeed the build, but consider the edge dirty, so it will re-execute next time ninja is called. I understand it may exist reason that in practice we do not want ninja to tend to a correct incremental build. |
@jdrouhard I think the only to make both approaches compatible will be to add a new column the build log to store the actual mtime of the output. There would be two mtimes: |
(The previous PR #1945 was closed automatically because of a branch renaming on my side, so I am re-opening a new one)
This pull request is a fix for #1946.
The Problem
The general problem I am trying to solve is improving the correctness of the incremental build. I think we can say the incremental build is correct when the result of running ninja is the same as doing a full build (enforcing all rule command to be executed again). Today there are at least two scenarios where this is not the case:
Example In Practice
My Solution
Today if an output of the build is modified from outside of the build system (manually or by another process) ninja will not consider it to be dirty.
My modification considered an output is dirty if its mtime is more recent than the one in the build log. The mtime of the output can be older than the one on the build log in the case its build edge is mark with 'restat = 1'. In that case if the rule command did not modified the output, its build log entry will inherit the mtime of its most recent inputs or depfile.
Also, since in some scenario like when you consciously modified outputs for quick testing you may not want ninja to override your change, my implementation makes it optional. For backward compatibility ninja keep the same default behavior, but if run with
-m
flag, it will considered modified outputs as dirty