Skip to content

Fix spurious rebuilds for phony targets with validations#2729

Open
codesuki wants to merge 4 commits intoninja-build:masterfrom
codesuki:validations
Open

Fix spurious rebuilds for phony targets with validations#2729
codesuki wants to merge 4 commits intoninja-build:masterfrom
codesuki:validations

Conversation

@codesuki
Copy link

Phony targets with no inputs are considered dirty if their output is missing. However, phony targets used as anchors for validation dependencies (e.g. from GN groups) often have no regular inputs but should not force a rebuild if the validations are clean.

This change updates RecomputeOutputDirty to check if a phony target has validation dependencies. If so, it is treated similarly to a target with inputs: it is only dirty if its dependencies are dirty, not automatically dirty because the output file is missing.

This fixes an issue where targets depending on a phony validation anchor would rebuild on every run.

Phony targets with no inputs are considered dirty if their output is missing.
However, phony targets used as anchors for validation dependencies (e.g. from GN groups)
often have no regular inputs but should not force a rebuild if the validations are clean.

This change updates RecomputeOutputDirty to check if a phony target has validation dependencies.
If so, it is treated similarly to a target with inputs: it is only dirty if its dependencies are dirty,
not automatically dirty because the output file is missing.

This fixes an issue where targets depending on a phony validation anchor would rebuild on every run.
Copy link
Contributor

@digit-google digit-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this looks fine, @jhasse please take a look.

src/graph.cc Outdated
@@ -285,7 +285,8 @@ bool DependencyScan::RecomputeOutputDirty(const Edge* edge,
if (edge->is_phony()) {
// Phony edges don't write any output. Outputs are only dirty if
// there are no inputs and we're missing the output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you add a segment in the comment that explains why validations_ is checked too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a small comment. Please let me know if that clarifies it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you!

@jhasse jhasse added this to the 1.14.0 milestone Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants