Skip to content

Fix spurious rebuilds for phony targets with validations#2729

Merged
jhasse merged 4 commits intoninja-build:masterfrom
codesuki:validations
Mar 3, 2026
Merged

Fix spurious rebuilds for phony targets with validations#2729
jhasse merged 4 commits intoninja-build:masterfrom
codesuki:validations

Conversation

@codesuki
Copy link
Contributor

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.

@jhasse jhasse added this to the 1.14.0 milestone Feb 16, 2026
@jhasse jhasse merged commit 0cd88be into ninja-build:master Mar 3, 2026
17 checks passed
@jhasse
Copy link
Collaborator

jhasse commented Mar 3, 2026

Thanks!

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