Missingdep and dynamic dependencies#2745
Open
moritzx22 wants to merge 8 commits intoninja-build:masterfrom
Open
Missingdep and dynamic dependencies#2745moritzx22 wants to merge 8 commits intoninja-build:masterfrom
moritzx22 wants to merge 8 commits intoninja-build:masterfrom
Conversation
4eb1f24 to
904b8fb
Compare
…file hook This change restructures depfile loading by introducing a const‑aware function helper and removing the virtual ProcessDepfileDeps path. NodeStoringImplicitDepLoader is updated accordingly. Behavior is unchanged; this prepares the codebase for future support of const 'Edge*' in dependency scanning.
67ff575 to
2d10da7
Compare
Collaborator
|
Ignore the codespell stuff ... I'm not sure if that shouldn't just be removed from CI. |
Prepare the missingdeps scanner for handling dependencies generated through dyndep files. This change loads dyndep information into a separate structure, making dyndep-generated inputs accessible to the scanner without modifying the existing dependency graph. No functional behavior is changed in this commit. This refactoring lays the groundwork for a follow-up change that will extend missingdeps to detect dyndep-generated inputs and outputs.
The 'ninja -t missingdeps' tool previously detected missing dependencies only for implicit inputs generated directly by the build manifest. Inputs generated through dyndep files were not considered, causing missing dependencies to go unnoticed. This commit extends the missingdeps scanner to also detect dyndep‑generated outputs, which correspond to the dependencies listed in the depfiles.
missingdeps now follows input dependencies introduced by dyndep files, not only those declared in the manifest. This ensures that dependency scanning correctly determines whether a path exists between two edges, including dynamically generated inputs. With this change, missing dependencies can now be fixed using dyndep-generated inputs.
… edge Nodes created via dyndep had no in_edge, causing missing‑deps checks to be skipped or incorrect. This patch resolves the dyndep in_edge, recurses into dyndep inputs, and passes the correct edge into ProcessNodeDeps.
This change introduces a second dependency‑consistency check, analogous to the existing 'missingdeps' mechanism, but applied to nodes generated through dyndep. The scanner now verifies that every dyndep output required by a requesting edge is guaranteed to be built before that edge executes, even in cases where the dyndep file has not yet been loaded. This ensures that incomplete or incorrect propagation of dyndep‑generated dependencies is detected early.
2d10da7 to
6a4bb40
Compare
This was referenced Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend 'ninja -t missingdeps' to Support Dyndeps
Currently, the
ninja -t missingdepssubtool does not take dynamic dependencies (dyndep) into account. This PR extends the functionality ofmissingdepsto properly follow and evaluate dyndep relationships.The example below demonstrates such a case:
A missing dependency is reported even though it is correctly satisfied through a dynamically generated input
generated.h.Show full `build.ninja` file
As of today, running
ninja -t missingdepson the first example produces:This is a false positive, since
generated.his actually provided via a dyndep relationship. However, because dyndeps are currently ignored by the missingdeps tool, the dependency path is not detected.Changes in This PR
Extend the missingdeps algorithm to:
Running the same example with the proposed
The false positive is resolved, as the tool now correctly follows dyndep relationships and recognizes that
generated.his properly generated before it is consumed.Missingdyndeps
This PR also introduces the concept of "missingdyndeps", analogous to missingdep from depfiles.
A missingdyndep occurs when:
In a well-defined build:
Example missingdyndep:
The following example demonstrates a missing dyndep situation:
Show full `build.ninja` file
In this setup, it is not guaranteed that the
dyn_touchedge runs before therequestedge if the dyndep file has not yet been loaded. As a result,generated.hmay be consumed before it is produced.The detection of
missingdyndepsis integrated into the existing missingdeps tool. When such a case is encountered, it is reported alongside the usual output.For the example above, the output becomes:
This indicates that while no traditional missingdeps were found, a missing dyndep condition was still detected.
Resolve example
This can be resolved by explicitly enforcing the correct build order, for example:
Both approaches ensure that the dynamic dependency is properly respected and that
generated.his generated before it is used.Here are the graphs without
missingdyndepsgraph click to show
Option 1:


Option 2: